C#中有任何控件可以保存文件吗? [英] is there any control in c# to save file?

查看:78
本文介绍了C#中有任何控件可以保存文件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C#中是否有任何控件可以在vb.net中保存文件,例如savefiledialogue?

还是有其他替代方法?

is there any control in c# to save file like savefiledialogue in vb.net?

or is there any other alternative?

推荐答案

相同的SaveFileDailog 也可以在C#中使用.广义上讲,.NET与语言无关
SaveFileDialog 在这里说明
http://msdn.microsoft.com/en-us/library/system. windows.forms.savefiledialog.aspx [ ^ ]
在该页面的语法"选项卡中可以看到,同时给出了C#, VB.

The same SaveFileDailog can be used in C# also. Broadly speaking, .NET is independent of languages
The SaveFileDialog is explained here
http://msdn.microsoft.com/en-us/library/system.windows.forms.savefiledialog.aspx[^]
As can be seen in the Syntax Tabs on that page, C#, VB both are given.

//Paste the following code in Load event of Form1

    SaveFileDialog saveFileDialog = new SaveFileDialog();

    saveFileDialog.ShowDialog();
    string fileName = saveFileDialog.FileName;
    MessageBox.Show(fileName);
    saveFileDialog.Dispose();

//If the file name is entered as MyFileName.txt in C: drive
//then the output will be
//C:\MyFileName.txt



要运行上述示例,请在Visual Studio中创建一个Windows Forms项目,在设计器中双击Form1,这将打开代码文件,将以上代码粘贴到Form1的Load事件中并运行该应用程序.



To run the above sample, create a Windows Forms project in Visual Studio, double click on Form1 in the designer, which opens the code file, paste the above code in the Load event of Form1 and run the application.


尝试 SaveFileDialog类 [ ^ ]-任何.NET类在VB中运行的代码也将在C#中运行(这是.NET背后的思想的一部分)
Try the SaveFileDialog Class[^] - any .NET class that works in VB will work in C# as well (that is part of the idea behind .NET)


这篇关于C#中有任何控件可以保存文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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