我自己的文件-创建 [英] My own files - Creation

查看:118
本文介绍了我自己的文件-创建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我不是专业的开发人员,但是我非常喜欢vb.net,有时我会创建一些应用程序.
现在我想问一个问题:
我正在开发一个简单的应用程序.在此应用程序中,您可以选择一个mp3文件和一个jpg文件并关联在一起.
那么我想将其保存在一个具有新扩展名的新文件中.
如何写这个文件?最重要的是,如何将这个文件与2个本地mp3和jpg文件取消关联?

预先谢谢大家

已从答案中移除:

谢谢大家的回答,也许我没有适当地抱怨:
假设有2个文件:2 mb的文件名A.mp3和1 mb的文件B.jpg.
在一个我想创建的虚拟应用程序中,然后写一个文件名C.jxx
它将是一个二进制文件,其中包括文件A.mp3 + B.jpg,如下所示:

Hello everybody I am not a professional developer but I like very much vb.net and sometimes i create some application.
Now I would like to to ask for a question:
I am working on an easy application. in this application you can select an mp3 file and one jpg file and associate toghether.
then I would like to save this in one new file with a new extension.
How can I write this file? and most of all, how can I read this file e un-associate the 2 native mp3 and jpg files?

Thank you in advance to everybody

Moved from answer:

Thank you everybody for your answer, maybe I did not exlaplain properly:
Let suppose have 2 files : file name A.mp3 of 2 mb and file B.jpg of 1 mb.
inside an hypothetical my own application I want to create then write a file name C.jxx
which it will be a binary file including files A.mp3 + B.jpg like this scheme:

_______________________________ ___________________________
||||||||| File A.mp3 |||||||||| + ||||||| File B.jpg ||||||||
_____________________________________________________________
||||||||||||||||||||||||| File C.jxx ||||||||||||||||||||||


写入文件c.jxx后,应用程序必须能够加载它
并返回到原始2个文件A.mp3和B.jpg,以便播放音乐和查看
图片.
Vb.net如何做到这一点?或C#,但不是.Net
一些想法?


Jorkax


once the file c.jxx has been written the application must be able to load it
and turn back to original 2 files A.mp3 and B.jpg in order to play the music and View
the pictures.
how would it be possible to do this with Vb.net? or C# but as you not is .Net
some ideas?


Jorkax

推荐答案

您可以将两个文件(即zip)一起存档,但由于无法使用本机mp3或图像应用程序而无法提取它们文件包含.
You can archive the two files together, i.e. zip, but you will not be able to extract them using native mp3 or image applications as they will not know what the file contains.


如Mark Nischalke所建议的那样,您可以将它们压缩在一起,也可以仅使用二进制连接来创建单个文件.然后,在运行时,您可以根据需要将文件提取到temp目录,然后将它们传递给最终使用者(可能是第三方应用程序).

另一方面,如果您的代码直接解析mp3和jpg,则可能无需提取文件,因为您可以轻松读取二进制数据流.您需要将文件的偏移量和长度保存在二进制归档文件的标头中或单独的文件中,但这很简单.
As Mark Nischalke suggested, you can either zip them up together or merely use a binary concatenation to create a single file. At runtime, you can then extract the files as required to a temp directory and then pass them to their final consumers (presumably 3rd party applications).

On the other hand, if your code directly parses both the mp3 and the jpg, you may not need to extract the files since you can easily read the binary stream of data. You''d need to save the file offsets and lengths in your binary archive''s header or in a separate file, but that would be quite trivial.


正如Mark所说的那样可以使用许多zip库之一来执行此操作,例如 SharpZipLib [
As Mark has already said you can use one of the many zip libraries to do this, such as SharpZipLib[^], although there are plenty of others if you search for something like free .net zip library.

The added advantage is that you will save a little space by zipping them.

The same library will enable you to extract them when you need to use them.


这篇关于我自己的文件-创建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆