怎么指定路径打开txt文档?

StudyCDD 2009-09-24 10:29:38
就像我们安装东西一样 可以选择位置一样的东西 并且只能打开txt的文档?谢谢了 帮帮菜鸟解决下
...全文
262 20 打赏 收藏 转发到动态 举报
写回复
用AI写文章
20 条回复
切换为时间正序
请发表友善的回复…
发表回复
tingtingsmile1988 2011-06-08
  • 打赏
  • 举报
回复
我也很想知道打开的文档时乱码是怎么回事?
StudyCDD 2009-09-24
  • 打赏
  • 举报
回复
[Quote=引用 17 楼 ojlovecd 的回复:]
引用 7 楼 studycdd 的回复:
那怎么弄呢?  我也不会用openFileDialog    把它拉到环境了然后怎么办呢?

我有个button 想点击button就出来提示框要你选择路径的
Dim strFile As String = OpenFileDialog1.ToString   ????

VB的?怎么跑到C#来发帖?
参考:
VB.NET codePrivateSub Button1_Click(ByVal senderAs System.Object,ByVal eAs System.EventArgs)Handles Button1.Click
OpenFileDialog1.Filter="*.txt|*.txt"If OpenFileDialog1.ShowDialog()= DialogResult.OKThen
System.Diagnostics.Process.Start(OpenFileDialog1.FileName)EndIfEnd Sub
[/Quote]


是啊 vb人都被灌水乐园的洪水冲走了 麻烦你给我说下 乱码是怎么回事 谢谢啦 怎么设置?
zhouguidi 2009-09-24
  • 打赏
  • 举报
回复
[Quote=引用 15 楼 studycdd 的回复:]
非常抱歉  感谢上面的都对着呢 我还想问下 我打开的文档全乱码? 是不是要设置 UTF-8 ? 我怎么找不到在哪设置呢?

如果不是与UTF-8有关 那麻烦你们告诉我下 谢谢你们了!
[/Quote]
notepad没有设置,你文件-另存为,可以选择编码方式,用utf8保存一份就行了
我姓区不姓区 2009-09-24
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 studycdd 的回复:]
那怎么弄呢?  我也不会用openFileDialog    把它拉到环境了然后怎么办呢?

我有个button 想点击button就出来提示框要你选择路径的
Dim strFile As String = OpenFileDialog1.ToString  ????
[/Quote]
VB的?怎么跑到C#来发帖?
参考:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
OpenFileDialog1.Filter = "*.txt|*.txt"
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
System.Diagnostics.Process.Start(OpenFileDialog1.FileName)
End If

End Sub

panzhaojl 2009-09-24
  • 打赏
  • 举报
回复
C#代码:

SaveFileDialog ADialog = new SaveFileDialog();
ADialog.DefaultExt = ".txt";
ADialog.Filter = "文本文件(*.txt)|*.txt";
ADialog.OverwritePrompt = true;
if (ADialog.ShowDialog() == DialogResult.OK)
{

}
Asp.net:直接托一个控件就好了。
StudyCDD 2009-09-24
  • 打赏
  • 举报
回复
非常抱歉 感谢上面的都对着呢 我还想问下 我打开的文档全乱码? 是不是要设置 UTF-8 ? 我怎么找不到在哪设置呢?

如果不是与UTF-8有关 那麻烦你们告诉我下 谢谢你们了!
随风落梦 2009-09-24
  • 打赏
  • 举报
回复
用process.start()可以打开
我姓区不姓区 2009-09-24
  • 打赏
  • 举报
回复

private void button1_Click(object sender, EventArgs e)
{
openFileDialog1.Filter = "*.txt|*.txt";
DialogResult dr = openFileDialog1.ShowDialog();
if (dr == DialogResult.OK)
{
System.Diagnostics.Process.Start(openFileDialog1.FileName);
}
}
yuan1238 2009-09-24
  • 打赏
  • 举报
回复
openfiledialog 控件!!!没错!!!
zhouguidi 2009-09-24
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 cstod 的回复:]
指定Filter为"文本文件(*.txt)|*.txt"。
[/Quote]

如楼上各位所说,设置openfiledialog的filter属性,
然后openfiledialog1.show();
然后string a=openfiledialog1.filename;
BitCoffee 2009-09-24
  • 打赏
  • 举报
回复
OpenFileDialog1的Filter属性设为:文本文件(*.txt)|*.txt
if (this.OpenFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
string path = this.OpenFileDialog1.FileName.ToString().Trim();
}
threenewbee 2009-09-24
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 studycdd 的回复:]
那怎么弄呢?  我也不会用openFileDialog    把它拉到环境了然后怎么办呢?

我有个button 想点击button就出来提示框要你选择路径的
Dim strFile As String = OpenFileDialog1.ToString  ????
[/Quote]

openFileDialog1.ShowDialog();
xunis 2009-09-24
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 caozhy 的回复:]
引用 3 楼 xunis 的回复:
引用 2 楼 caozhy 的回复:
openFileDialog
指定Filter为*.txt。


*.txt 提示是无效值



*.txt|*.txt ? 你看下MSDN。
[/Quote]


[Quote=引用 6 楼 cstod 的回复:]
指定Filter为"文本文件(*.txt)|*.txt"。
[/Quote]


是 文本文件(*.txt)|*.txt
StudyCDD 2009-09-24
  • 打赏
  • 举报
回复
那怎么弄呢? 我也不会用openFileDialog 把它拉到环境了然后怎么办呢?

我有个button 想点击button就出来提示框要你选择路径的
Dim strFile As String = OpenFileDialog1.ToString ????
CsToD 2009-09-24
  • 打赏
  • 举报
回复
指定Filter为"文本文件(*.txt)|*.txt"。
threenewbee 2009-09-24
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 xunis 的回复:]
引用 2 楼 caozhy 的回复:
openFileDialog
指定Filter为*.txt。


*.txt  提示是无效值


[/Quote]
*.txt|*.txt ? 你看下MSDN。
CsToD 2009-09-24
  • 打赏
  • 举报
回复
Process.Start("D:\\a.txt");
???
xunis 2009-09-24
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 caozhy 的回复:]
openFileDialog
指定Filter为*.txt。
[/Quote]

*.txt 提示是无效值

threenewbee 2009-09-24
  • 打赏
  • 举报
回复
openFileDialog
指定Filter为*.txt。
grearo 2009-09-24
  • 打赏
  • 举报
回复
openFileDialog控件

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧