62,268
社区成员
发帖
与我相关
我的任务
分享private string ProcessBrochureUpload(FileUpload VideoUpload, out bool CancelOperation)
{
CancelOperation = false; // by default, do not cancel operation
if (VideoUpload.HasFile)
{
// Make sure that a PDF has been uploaded
if (string.Compare(System.IO.Path.GetExtension(VideoUpload.FileName), ".flv", true) != 0)
{
UploadWarning.Text = "上传的视频文件格式不对!!只能是flv文件!!";
UploadWarning.Visible = true;
CancelOperation = true;
return null;
}
const string VideoDirectory = "~/UrlData/Video/";
string VideoPath = VideoDirectory + VideoUpload.FileName;
string fileNameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(VideoUpload.FileName);
int iteration = 1;
while (System.IO.File.Exists(Server.MapPath(VideoPath)))
{
VideoPath = string.Concat(VideoDirectory, fileNameWithoutExtension, "-", iteration, ".flv");
iteration++;
}
// Save the file to disk and set the value of the brochurePath parameter
VideoUpload.SaveAs(Server.MapPath(VideoPath));
return VideoPath.Substring(1,VideoPath.Length-1);
}
else
{
// No file uploaded
return null;
}
}