我在编写文件夹和子文件夹中的文件时遇到问题。
例如: - test是主文件夹
1)C:\ test \
我希望阅读和编写子文件夹文件
2)C:\测试\ 2011年12月5日\ 12-05-2011.txt
3)C:\测试\ 13-05-2011 \ 13-05-2011.txt
4)C:\测试\ 14-05-2011 \ 14-05-2011.txt
我的代码是。
private void button1_Click(object sender, EventArgs e)
{
const string Path1 = @"C:\test";
DoOnSubfolders(Path1);
try
{
StreamReader reader1 = File.OpenText(Path1);
string str = reader1.ReadToEnd();
reader1.Close();
reader1.Dispose();
File.Delete(Path1);
string[] Strarray = str.Split(new char[] { Strings.ChrW(10) });
int abc = Strarray.Length - 2;
int xyz = 0;
while (xyz <= abc)
{
try
{
string[] strarray1 = Strarray[xyz].Split(",".ToCharArray());
string SecName = strarray1[0];
string SecSym = strarray1[1];
int DT = int.Parse(strarray1[2]);
int TM = int.Parse(strarray1[3]);
float O = float.Parse(strarray1[4]);
float H = float.Parse(strarray1[5]);
float L = float.Parse(strarray1[6]);
float C = float.Parse(strarray1[7]);
double V = double.Parse(strarray1[8]);
double OI = double.Parse(strarray1[9]);
BTLReaderClass class2 = new BTLReaderClass();
BTLWriterClass class3 = new BTLWriterClass();
if (! Directory.Exists("C:\\Sample1"))
{
class3.CreateDirectory("C:\\Sample1");
}
else if (! File.Exists("C:\\Sample1\\RMaster"))
{
class3.CreateDirectory("C:\\Sample1");
}
class3.OpenDirectory("C:\\Sample1");
if (! class3.get_bSymbolExists(SecSym))
{
class3.AppendISecurity(SecSym, SecName, INTERVAL.Minute60 );
class3.CloseSecurity();
class3.CloseDirectory();
class3.OpenDirectory("C:\\Sample1");
class3.OpenSecurityBySymbol(SecSym);
class3.DataRec(DT, TM, O, H, L, C, (float) V, (float) OI);
class3.CloseSecurity();
class3.CloseDirectory();
}
else if (class3.get_bSymbolExists(SecSym))
{
class2.OpenDirectory("C:\\Sample1");
class2.OpenSecurityBySymbol(SecSym);
class2.SeekToEnd();
class2.Seek(-1);
class2.ReadDay();
int OldTime = class2.iSeTime;
int OldDate = class2.iSeDate;
float OldO = class2.dSeOpen;
float OldH = class2.dSeHigh;
float OldL = class2.dSeLow;
float OldC = class2.dSeClose;
double OldV = class2.dSeVolume;
double OldOI = class2.dSeOpenInterest;
class2.CloseSecurity();
class2.CloseDirectory();
if (OldTime != TM | OldDate != DT)
{
class3.OpenSecurityBySymbol(SecSym);
class3.AppendIData(DT, TM, O, H, L, C, (float) V, (float) OI);
class3.CloseSecurity();
class3.CloseDirectory();
}
else
{
class3.OpenSecurityBySymbol(SecSym);
class3.LastRecord(DT, TM, O, H, L, C, (float) V, (float) OI);
class3.CloseSecurity();
class3.CloseDirectory();
}
}
}
catch (Exception)
{
//MsgBox("Error" & ex1.Message)
}
xyz++;
}
}
catch (Exception)
{
//MsgBox("Error" & ex.Message)
}
}
我收到错误错误是访问路径'C:\ test'被拒绝。
任何人都可以说我需要在此代码中更改内容。
请帮助我们
提前致谢