我厌倦了将循环病毒签名写入文件。我的代码:
for (int i = 0; i < liczba; i++)
{
int current = i + 1;
string xxx = w.DownloadString("xxx(hidden)");
if (xxx != "0")
{
string[] wirus = xxx.Split("|||".ToCharArray());
string s2 = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "_RDTSignatures", "base000" + current.ToString() + ".rdtsignature");
File.Create(s2);
StreamWriter sss = new StreamWriter(s2); //that's crash line
sss.WriteLine("hidden");
sss.WriteLine(wirus[0]);
sss.WriteLine(wirus[1]);
sss.Close();
File.Encrypt(s2);
}
}
w
是一个WebClient
对象。错误回调:
System.IO.IOException: Process cannot access file : „C:\Users\Pluse Konto\Documents\Visual Studio 2010\Projects\Radzik Diagnostic Tool\Radzik Diagnostic Tool\bin\Debug\_RDTSignatures\base0001.rdtsignature”, because it is used by other process.
w System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
w System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
w System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
w System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost)
w System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost)
w System.IO.StreamWriter..ctor(String path)
w Radzik_Diagnostic_Tool.Updates.timer1_Tick(Object sender, EventArgs e) w C:\Users\Pluse Konto\documents\visual studio 2010\Projects\Radzik Diagnostic Tool\Radzik Diagnostic Tool\Updates.cs:line 69
w System.Windows.Forms.Timer.OnTick(EventArgs e)
w System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
w System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
我不知道该错误的原因是什么。当然,除了我的主线程之外,没有任何进程在使用我的文件。
PS 文件base0001.rdtsignature
已创建,但为空。