我使用File.Create()新建一个cad文件,可以新建成功,但是文件无法打开。通过File.Create()创建的cad文件始终为0kb,而我通过鼠标右击新建的cad文件一般为10kb,(这点差异可能是导致文件无法打开的原因),我如何在程序中实现像通过鼠标右击新建的功能呢?
我的代码如下:
String path="D:\\catia.CATProduct";
File.Create(path).Close();
ps:我新建的cad文件扩展名为:.CATProduct。
我的代码如下:
String path="D:\\catia.CATProduct";
File.Create(path).Close();
ps:我新建的cad文件扩展名为:.CATProduct。
HKEY_CLASSES_ROOT\.pptx\PowerPoint.Show.12\ShellNew看看能不能找到命令或者文件很多情况其实系统根本就没有创建文件,只是将模板文件复制过来,比如说powerpoint就是这样
try
{
if (File.Exists(path))
{
File.Delete(path);
}
// Create the file.
using (FileStream fs = File.Create(path))
{
Byte[] info = new UTF8Encoding(true).GetBytes("This is some text in the file.");
// Add some information to the file.
fs.Write(info, 0, info.Length);
}
// Open the stream and read it back.
using (StreamReader sr = File.OpenText(path))
{
string s = "";
while ((s = sr.ReadLine()) != null)
{
Console.WriteLine(s);
}
}
}
catch (Exception Ex)
{
Console.WriteLine(Ex.ToString());
}试了没问题生成30字节 1K
cad文件格式首先你要知道,文件头,文件主体等等,文件内部结构要很清晰才能自己DIY