广东成教网:如何用C#实现视频文件上传
来源:百度文库 编辑:杭州交通信息网 时间:2024/06/10 18:17:25
HttpPostedFile f = File1.PostedFile;//这个知道是什么吧
string FileName = GetUniquelyString(); //获取一个不重复的文件名
string FileOrginName = f.FileName.Substring(f.FileName.LastIndexOf("\\") + 1);//获取文件的原始名
if (f.ContentLength > 0)
{
String postFileName;
String FilePath = Server.MapPath(".\\photo").ToString();
string path = FilePath + "\\";
try
{
int pos = f.FileName.LastIndexOf(".") + 1;
postFileName = f.FileName.Substring(pos, f.FileName.Length - pos);
f.SaveAs(path + FileName + "." + postFileName); //存储指定的文件到指定的目录
}
catch (Exception exec)
{
throw (exec);
}
double unit = 1024;
string fpname = FileOrginName.Remove(FileOrginName.Length - postFileName.Length - 1);