c#中无法创建system.io.file实例

来源:百度知道 编辑:UC知道 时间:2024/07/07 08:13:01
if(ClientCommand=="down")
{
bool check =false;
string temp=clientmessage.Substring(4);
string mes=temp.Trim();
string fullpath=filedown+mes;

File ftemp=new File(filedown+mes);
check=true;
if(check&&allowdown )
{
SendMessage(mySocket,"size"+ftemp.ToString());
ftemp=null;
}
else if(check&&!allowdown )
{
SendMessage(mySocket,"nope download not allowed!");
}
else{
SendMessage(mySocket,"nope file now found");
}
ftemp=null;
return true;
}

其中 File ftemp=new Fil

File是静态类,不能创建实例。
File.WriteAllText(string path,string contens)可以实现创建文件。

File 是静态类,使用它提供的方法不需要实例化
如 File.Copy(sourcefile,targetfile) 这样使用就可以了
FileInfo 是对应的需要实例化的文件操作类