C#中有任何控件可以保存文件吗?

编程入门 行业动态 更新时间:2024-10-27 08:36:47
本文介绍了C#中有任何控件可以保存文件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

C#中是否有任何控件可以在vb中保存文件,例如savefiledialogue? 还是有其他替代方法?

is there any control in c# to save file like savefiledialogue in vb? or is there any other alternative?

推荐答案

相同的SaveFileDailog 也可以在C#中使用.广义上讲,.NET与语言无关 SaveFileDialog 在这里说明 msdn.microsoft/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 msdn.microsoft/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#中有任何控件可以保存文件吗?

本文发布于:2023-10-23 04:21:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1519767.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:中有   控件   保存文件

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!