請告訴我爲什麼file.Delete(gpath)不工作?如何刪除C文件#
我會非常感謝你:)如果在這段代碼上有任何錯誤,那麼就告訴你這個錯誤。這段代碼可能是錯誤的,所以請告訴我。
string gpath;
string [email protected]"c:\Users\Adam\Desktop\";
string name="file";
string f="";
int i=0;
string ext=".txt";
while(File.Exists(path + name + f + ext))
{
i++;
f = i.ToString();
}
gpath = path + name + f + ext;
button2.Enabled = true;
File.Create(gpath);
File.Delete(gpath);//why there is an Error??
呃,什麼錯誤? – Crisfole
我想你可以做'File.Create(gpath).Close();'你正在創建和刪除文件的任何原因立即? –
感謝凱文DiTragila :) –