简体   繁体   中英

C# mp4 resource file high storage

I was looking for block that way who wants copy the mp4 files And I'm finding the way, that i changed mp4 file to resource By this way:

    private void Form1_Load(object sender, EventArgs e)
    {
    String openVideo = @"c:\temp\video.mp4";
    System.IO.File.WriteAllBytes(openVideo, global::ProjectName.Properties.Resources.mymp4name);            
    System.Diagnostics.Process.Start(openVideo); 
    }

it works! But after the debug a software All of the storage of that saved in the exe file and this is so heavy for a file , and is there any way to save that resourse file Separate and exe file just do the software?

If you want to storage files, no matter the type you can use "FileStream".

private void SaveFile(string _pathToGet, string _pathToSave)
{
    FileStream fs = new FileStream();
    byte[] = GetFile(_pathToGet);
    fs.Write(data, 0, data.Length);
}

private byte[] GetFile(_path)
{
    FileStream fs = null;
    fs = File.Open(_path, FileMode.Open, FileAccess.Read);
    byte[] data = new byte[fs.Length];
    fs.Read(data, 0, (int)fs.Length);
    fs.Close();
    return data;
}

That's may help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM