打开文件

zqsntws 2006-01-11 10:52:16
我在datagrid里有一列是超链列,点击该列会弹出“打开,保存,取消,信息”的WINDOW提示框,用户可以把该文件保存到本地,也可以直接打开该文件,能否把打开按钮灰掉?或是隐藏该按钮?
...全文
133 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
zqsntws 2006-01-13
  • 打赏
  • 举报
回复
怎么让用户选择路径,然后调用我的过程把选择的文件保存到指定目录下?
zqsntws 2006-01-12
  • 打赏
  • 举报
回复
我还想让用户自己选择保存的路径,这个怎么实现?
time_is_life 2006-01-11
  • 打赏
  • 举报
回复
不可以,除非你用StreamWriter自己将文件流写到本地,而不是用IE的下载功能。

---------------------------------------
using System;
using System.IO;

class Test
{
public static void Main()
{
try
{
// Create an instance of StreamReader to read from a file.
// The using statement also closes the StreamReader.
using (StreamReader sr = new StreamReader("TestFile.txt"))
{
String line;
// Read and display lines from the file until the end of
// the file is reached.
while ((line = sr.ReadLine()) != null)
{
Console.WriteLine(line);
}
}
}
catch (Exception e)
{
// Let the user know what went wrong.
Console.WriteLine("The file could not be read:");
Console.WriteLine(e.Message);
}
}
}

--------------------------------------------------------

using System;
using System.IO;

class Test
{
public static void Main()
{
// Create an instance of StreamWriter to write text to a file.
// The using statement also closes the StreamWriter.
using (StreamWriter sw = new StreamWriter("TestFile.txt"))
{
// Add some text to the file.
sw.Write("This is the ");
sw.WriteLine("header for the file.");
sw.WriteLine("-------------------");
// Arbitrary objects can also be written to the file.
sw.Write("The date is: ");
sw.WriteLine(DateTime.Now);
}
}
}
zqsntws 2006-01-11
  • 打赏
  • 举报
回复
这个方法可以读出别的类型的文件吗?比如word文件的内容,或是pdf的文件?

62,041

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

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