111,096
社区成员




public bool FuJianCreateFile() {
try
{
FileStream fs = new FileStream("要上传的文件路径", FileMode.Open, FileAccess.Read);
byte[] b = new byte[fs.Length];
fs.Read(b, 0, (int)fs.Length);
string newFilePath = "服务器存放的路径";
string fileName = "文件名";
if (!Directory.Exists(newFilePath))
{
Directory.CreateDirectory(newFilePath);
}
newFilePath = Path.Combine(newFilePath, fileName);
MemoryStream m = new MemoryStream(b);
FileStream f = new FileStream(newFilePath, FileMode.Create);
m.WriteTo(f);
m.Close();
f.Close();
f = null;
m = null;
return true;
}
catch
{
return false;
}
}