protected void Button1_Click(object sender, EventArgs e)//从这开始点击BUTTON上传文件。
    {
if (this.FileUpload1.HasFile)
{
string saveName=DateTime.Now.Ticks.ToString();
string FilePath = Server.MapPath(".");
string m_strExtension = GetExtension(this.FileUpload1.PostedFile.FileName).ToLower();
string FileName=saveName+"."+m_strExtension;
this.FileUpload1.SaveAs(FilePath+"/"+FileName);
if (m_strExtension == "flv")
{
System.IO.File.Copy(Server.MapPath(FileName), Server.MapPath("Source_Flv/"+saveName+".flv"));
return;
}
string a=VideoConvertFlv(Server.MapPath(FileName),Server.MapPath("Source_Flv/"+saveName+".flv"),"200x200");
            Response.Write(a);
}
}
public string VideoConvertFlv(string FromNamePath,string ExportNamePath,string WidthAndHeight)
{
  string ffmpeg=Server.MapPath("ffmpeg.exe");
  System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(ffmpeg);
  startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
          startInfo.Arguments = " -i " + FromNamePath + " -ab 56 -ar 22050 -b 500 -r 15 -s " + WidthAndHeight + " " + ExportNamePath;
  try 
  {
  System.Diagnostics.Process.Start(startInfo);
  //return ExportName;
  System.IO.File.Delete(FromNamePath);
  }
  catch(Exception err)
  {
     System.IO.File.Delete(FromNamePath);
  return err.Message;
  }
          return "OK"; }
public string GetExtension(string fileName)
{
int i = fileName.LastIndexOf(".")+1;
string Name = fileName.Substring(i);
return Name;
}

解决方案 »

  1.   

    不会不出错,是你看不到而已……应该是权限问题,
    你又是copy又是delete我怀疑是权限不够!
      

  2.   

    没权限他应该报错识呀。。
    放心权限是绝对的Administrator级别的
      

  3.   

    试着把try{}catch{}去掉看一看会不会报错?
    被捕捉了 !
      

  4.   

      try  
      { 
      System.Diagnostics.Process.Start(startInfo); 
      //return ExportName; 
      System.IO.File.Delete(FromNamePath); 
      }   catch(Exception err) 
      { 
         //System.IO.File.Delete(FromNamePath); 
      return err.Message; 
      } 
    把System.IO.File.Delete(FromNamePath); 注释掉,看一下
      

  5.   

    去了也不行。。他还是不升成FLV文件
      

  6.   

    1.你把下面这些代码也放在try{}catch()中,运行一下,看会不会提示出错。
      string ffmpeg=Server.MapPath("ffmpeg.exe"); 
      System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(ffmpeg); 
      startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; 
              startInfo.Arguments = " -i " + FromNamePath + " -ab 56 -ar 22050 -b 500 -r 15 -s " + WidthAndHeight + " " + ExportNamePath; 2.你是调用进程来执行转换操作,检查一下你设置的运行参数有没有错误。我是认为可能是你的ffmpeg.exe这个应用程序在调用时,程序的绝对路径可能有问题。这个应该是程序运行的机子上的ffmpeg.exe的绝对路径。
      

  7.   

    我在windows service里面也出现过类似你说的问题,晚上发我的解决方法
      

  8.   

    我试验用来备份oracle数据库的程序
      1 private static Process DBProecess = new Process();
                         
      2 DBProecess.StartInfo.FileName = @"d:\oracle\ora92\bin\exp.exe";
                        sPath = sPath.EndsWith("\\") ? sPath : sPath + "\\";
                        DBProecess.StartInfo.Arguments = @"user/pass@ora file=" + sPath + arg;
                        DBProecess.StartInfo.UseShellExecute = false;
                        DBProecess.StartInfo.RedirectStandardOutput = true;
                        DBProecess.Start();
                        string strRst = DBProecess.StandardOutput.ReadToEnd();
                        DBProecess.Close();
                        
    你可以看看用这样的方式来执行你的转换