[英]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: 我一直在寻找阻止谁复制mp4文件的方法,然后我找到了将mp4文件更改为资源的方法:
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?
但是,在调试软件后,所有存储在exe文件中的存储对该文件来说是如此之重,并且有什么方法可以将该资源文件保存为单独的文件和exe文件吗?
If you want to storage files, no matter the type you can use "FileStream". 如果要存储文件,则无论类型如何,都可以使用“ 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. 这可能会有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.