If (File.Exists("c:\\temp\\"+Text1.Value))
File.Delete("c:\\temp\\"+Text1.Value);
end if
File1.PostedFile.SaveAs("c:\\temp\\"+Text1.Value);
File.Delete("c:\\temp\\"+Text1.Value);
end if
File1.PostedFile.SaveAs("c:\\temp\\"+Text1.Value);
If (File.Exists("c:\\temp\\"+Text1.Value))
File.Delete("c:\\temp\\"+Text1.Value);
end if上面的File是怎么来的,我把它加在HTML代码中不对呀!
用上面的命名时,提示“对路径“C:\temp\1.jpg”的访问被拒绝。 ”怎么办呀!!!!
file就是上传文件得file控件得id啊,好像要新建一个file对象
用2003的朋友注意到没有,所有目录的属性都是一个阴影的“只读”这是为什么?
如是,就删除,然后再放上去
否则就直接放上去就可以了
可是删除不了,只要是在C:\\Inetpub\\wwwroot\\下就没有办法删除,
真的能删除C:\\Inetpub\\wwwroot\\下的文件吗?
mymail:[email protected]
winform是可以,但webform的就不行,我做的是asp.net的B/S,所以还是不行!
//获取文件长度
int xmlFileLen = InsXmlFile.PostedFile.ContentLength;
//获取文件名
string xmlFileName = InsXmlFile.PostedFile.FileName;
//获得文件流
byte[] xmlFilebuffer = new byte[xmlFileLen];
Stream xmlFileStream = InsXmlFile.PostedFile.InputStream;
xmlFileStream.Read(xmlFilebuffer,0,xmlFileLen); //在服务器端保存文件
HttpPostedFile postFile = new HttpPostedFile();
postFile.ContentLength = xmlFileLen;
postFile.FileName = xmlFileName;
postFile.InputStream = xmlFileStream;
string serverXmlFileName = Server.MapPath + "temp.xml";
if(File.Exists(serverXmlFileName))
{
File.Delete(serverXmlFileName);
postFile.SaveAs(serverXmlFileName);
}
//将文件写入到数据库中
RightFactory rightFac = new RightFactory();
IRight iRight = rightFac.CreateInstance();
iRight.InsertRightFromFile(pageHelper.DataID,serverXmlFileName);
//删除服务器端文件
if(File.Exists(serverXmlFileName))
{
File.Delete(serverXmlFileName);
}