WPF用。WinFormsも恐らく可。
特定カラムの伏字化。
ポインタで書き換えてます。
下記サンプルでは3か所の伏字化です。
using System.IO;
using System.Text;
using System.Windows;
using System.Windows.Input;
namespace TASKTEST {
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
using (StreamReader sr = new StreamReader(@"C:\ALLDATA.CSV",Encoding.GetEncoding("Shift_JIS"))) // idm_alldata.csv
using (StreamWriter sw = new StreamWriter(@"C:\NEWDATA.CSV",false, Encoding.UTF8)){ // output
while (sr.Peek() != -1){
string s=sr.ReadLine();
// if (s.Contains("ユーザID")) continue;
int t=0;
int x2=0,x3=0,x4=0,x5=0,x6=0,x7=0;
for (int i = 0; i < s.Length; i++){
if (s[i]==',') t++;
if (t==6) x2=i+1; // 6 == 6個目の ,
if (t==7) x3=i+1;
if (t==76) x4=i+1;
if (t==77) x5=i+1;
if (t==83) x6=i+1;
if (t==84) x7=i+1;
}
for (int v = x2+1; v < x3; v++) {
unsafe{
fixed(char* c = s){
c[v] = 'X';
}
}
}
for (int v=x4+1;v<x5;v++){
unsafe{
fixed(char* c = s){
c[v] = 'X';
}
}
}
for (int v=x6+1;v<x7;v++){
unsafe{
fixed(char* c = s){
c[v] = 'X';
}
}
}
sw.WriteLine(s);
}
// sw.Close();
// sr.Close();
}
}
}
}