using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;//streamnamespace test11
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent(); try
{
StreamWriter outStream = new StreamWriter("E://html//gg.html", false, Encoding.GetEncoding("GB2312"));
}
catch (IOException e)
{
System.Console.WriteLine("错误:" + e); }
}
}
}/*
在 System.IO.DirectoryNotFoundException 中第一次偶然出现的“mscorlib.dll”类型的异常
错误:System.IO.DirectoryNotFoundException: 未能找到路径“E:\html\gg.html”的一部分。
在 System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
在 System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
在 System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
在 System.IO.StreamWriter.CreateFile(String path, Boolean append)
在 System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize)
在 System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding)
*/
前几天还好好的,昨天就出现这样的问题了,求助大神,毕业设计问题
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;//streamnamespace test11
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent(); try
{
StreamWriter outStream = new StreamWriter("E://html//gg.html", false, Encoding.GetEncoding("GB2312"));
}
catch (IOException e)
{
System.Console.WriteLine("错误:" + e); }
}
}
}/*
在 System.IO.DirectoryNotFoundException 中第一次偶然出现的“mscorlib.dll”类型的异常
错误:System.IO.DirectoryNotFoundException: 未能找到路径“E:\html\gg.html”的一部分。
在 System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
在 System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
在 System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
在 System.IO.StreamWriter.CreateFile(String path, Boolean append)
在 System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize)
在 System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding)
*/
前几天还好好的,昨天就出现这样的问题了,求助大神,毕业设计问题
解决方案 »
- 关于GPS的转换一点疑问?
- 如何编程引用本地rdlc报表中的某列?
- C# winform 程式中如何做到打开一个画面同时关闭该画面
- 关于wmi得问题,比较难,听听大家的意见, 请看清楚 注明(最好不要用ServiceController 这个类)。
- Gagaga兄弟请进????安装问题请教一下。。。 如何不声不响的给用户安装了 .NET Framework
- c#与数据库Access连接问题
- 怎样去掉winform的datagrid自动填充列
- 根据输入的字符串,生成特定的格式的字符串,求简单方法
- 请问哪位朋友能帮忙解决解决代码中的错误!
- 关于XML 解析器的选择
- C# 中怎么操作Dll?
- webbrowser控件中网页无法跳转问题
试试?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;//streamnamespace test11
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent(); try
{
StreamWriter outStream = new StreamWriter("E:\\html\\gg.html", false, Encoding.GetEncoding("GB2312"));
}
catch (IOException e)
{
System.Console.WriteLine("错误:" + e); }
}
}
}/*
在 System.IO.DirectoryNotFoundException 中第一次偶然出现的“mscorlib.dll”类型的异常
错误:System.IO.DirectoryNotFoundException: 未能找到路径“E:\html\gg.html”的一部分。
在 System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
在 System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
在 System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
在 System.IO.StreamWriter.CreateFile(String path, Boolean append)
在 System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize)
在 System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding)
*/
是新建一个文件,程序中的代码在创建stream后还 outStream.Write(buffer);
如果目录不存在就创建目录,创建目录后再创建文件
怎么实现? file.create? 还是必须先Directory.Create()?
----------------------------------
回10L
/// <summary>
/// 创建文件夹
/// </summary>
/// <param name="folderPath">文件夹地址</param>
public static void CreatFolder(string folderPath)
{
if (!Directory.Exists(folderPath))//如果不存在就创建file文件夹
Directory.CreateDirectory(folderPath);//创建该文件夹
}
if(!file.exit())
if(!directory.exit()){
directory.create();
file.create();
}
路径和文件都需要创建
看到这样的路经,实在让我长了不少见识