[C# Express 2008] Problem on executing program with parameter directory japanese
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: [C# Express 2008] Problem on executing program with parameter directory japanese

  1. #1
    Join Date
    Dec 2008
    Posts
    4

    Question [C# Express 2008] Problem on executing program with parameter directory japanese

    Hello to everyone, first of all sorry for my bad english, I will try to explain my problem.
    I am trying to make a simple program in c# that using the sofware FFMpeg: http://www.videohelp.com/tools/ffmpeg
    can extract some information from the output created from it.
    So I just created a ProcessStartInfo(pathofffmpeg , parameters)
    where parameters it's a string just like that:
    " -i pathoffileandfile.avi"
    All work fine if the directory or the file have just normal ascii code, but as per example I have to extract information from that file:
    E:\春の朝は寒い\Somefile.avi
    then I just get from ffmpeg an error because can't get the file E:\??????\Somefile.avi and as you can see the ?????? substitute the correct character of the path.
    So I did another try, I went to my XP pc and change Locale to japanese, and try to execute the same command inside a BAT file or just from command prompt and that work !
    ffmpeg parameters input expected to be codified into UTF-8 format and actually I tried it too as follow:

    string Params = string.Format("-i \"{0}\"", @input.Path);
    Encoding srcEncodingFormat = Encoding.GetEncoding("UTF-16LE"); // standard for string ??
    Encoding dstEncodingFormat = Encoding.UTF8;
    byte[] originalByteString = srcEncodingFormat.GetBytes(Params);
    byte[] convertedByteString = Encoding.Convert(srcEncodingFormat,
    dstEncodingFormat, originalByteString);
    string finalString = dstEncodingFormat.GetString(convertedByteString);

    string output = RunProcess(finalString);

    where RunProcess it's that function

    private string RunProcess(string Parameters)
    {
    //create a process info
    ProcessStartInfo oInfo = new ProcessStartInfo(this.FFmpegPath, Parameters);
    oInfo.UseShellExecute = false;
    oInfo.CreateNoWindow = true;
    oInfo.RedirectStandardOutput = true;
    oInfo.RedirectStandardError = true;
    //Create the output
    string output = null;
    //try the process
    try
    {
    //run the process
    Process proc = System.Diagnostics.Process.Start(oInfo);
    //now put it in a string
    output = proc.StandardError.ReadToEnd();
    //Wait for exit
    proc.WaitForExit();
    //Release resources
    proc.Close();
    }
    catch (Exception)
    {
    output = string.Empty;
    }
    return output;
    }

    Results, not working Any suggestion about what to do ?????

  2. #2
    Join Date
    Dec 2008
    Posts
    4

    Re: [C# Express 2008] Problem on executing program with parameter directory japanese

    No one have any clue about it ???

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center