system.io.file创建
在实际开发中,如果用的文件名不能确定位置。或名字。可以使用GUID类来命名函数。Guid 结构标识全局唯一标示符。其NewGuid结构可以初始化一个新历。该方法语法格式如下:
public static Guid NewGuid();
return: 初始化后的实例。
源码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data; using System.Drawing;
using System.Linq; using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
namespace WindowsFormsApplication47
{ public partial class Form1 : Form
{ public Form1()
{ InitializeComponent(); }
private void button2_Click(object sender, EventArgs e)
{ FolderBrowserDialog p_folderbrowserdialog = new FolderBrowserDialog();
if(p_folderbrowserdialog .ShowDialog ()==DialogResult.OK )
{ File.Create(p_folderbrowserdialog.SelectedPath + "\\" + Guid.NewGuid().ToString() + ".txt"); } }
private void button1_Click(object sender, EventArgs e)
{ FolderBrowserDialog p_folderbrowserdialog = new FolderBrowserDialog();
if(p_folderbrowserdialog .ShowDialog ()==DialogResult.OK )
{ Directory.CreateDirectory(p_folderbrowserdialog.SelectedPath + "\\" + Guid.NewGuid().ToString()); } } } }
system.io.file创建的更多相关文章
- 详解C#中System.IO.File类和System.IO.FileInfo类的用法
System.IO.File类和System.IO.FileInfo类主要提供有关文件的各种操作,在使用时需要引用System.IO命名空间.下面通过程序实例来介绍其主要属性和方法. (1) 文件打开 ...
- System.IO.File类和System.IO.FileInfo类
1.System.IO.File类 ※文件create, copy,move,SetAttributes,open,exists ※由于File.Create方法默认向所有用户授予对新文件的完全读写. ...
- System.IO.File.Create 不会自动释放,一定要Dispose
这样会导致W3P进程一直占用这个文件 System.IO.File.Create(HttpContext.Current.Server.MapPath(strName)) 最好加上Dispose Sy ...
- IIS目录下文件共享后System.IO.File.Exists返回false
场景:在iis目录下,因为特殊需要共享一个文件夹,给到其他的技术人员访问,突然发现小小的操作,搞“大”了,使用 string path = Server.MapPath("~/file/te ...
- System.IO.File.WriteAllText("log.txt", "dddd");
System.IO.File.WriteAllText("log.txt", "dddd");
- 关于 System.IO.File.Exists 需要注意的事项
各位: .NET Framework 本省在设计的时候,他对于异常没有完全做到抛出,这样可能会有很多意想不到的问题. 比如 你在asp.net 应用程序中判断文件是否存在,这个文件可能是一个共 ...
- C# System.IO.File
using System; using System.IO; class Test { public static void Main() { string path = @"c:\temp ...
- 未处理的异常:system.io.file load exception:无法加载文件或程序集“ 。。。。 找到的程序集的清单定义与程序集引用不匹配。
问题描述: 添加控制器的时候,突然就报了这个错: Unhandled Exception: System.IO.FileLoadException: Could not load file or as ...
- 安卓上为什么不能用system.io.file读取streammingAssets目录下的文件
首先,看文档: Streaming Assets Most assets in Unity are combined into the project when it is built. Howe ...
随机推荐
- Java定时器:Timer
项目中往往会遇到需要定时的任务,例如订单,当用户在某个规定时间内没有操作订单时,订单状态将会发生改变. 那么在这种情况下,我们会用到定时器. 举例: import java.util.Timer; / ...
- uva 10129 poj 1386 hdu 1116 zoj 2016 play on words
//本来是想练一下欧拉回路的,结果紫书上那题是大水题!!!!! 题意:给出n个单词,是否可以把单词排列成每个单词的第一个字母和上一个单词的最后一个字母相同 解:欧拉通路存在=底图联通+初度!=入度的点 ...
- poj2000---和1969一样的模板
#include <stdio.h> #include <stdlib.h> int main() { int d; while(scanf("%d",&a ...
- libvirt python binding 变成了一个新项目了。
http://libvirt.org/git/ $ git clone git://libvirt.org/libvirt-python.git 2013年的事情了. $ git show a7a12 ...
- powerpc e500系列,linux初始化的tlb汇编,添加人肉代码注释
powerpc e500的内核启动,关于tlb的初始化可以说是重头戏.看懂这段代码后,powerpc的虚实映射基本不在话下. 这段初始化tlb要考虑的,主要是将boot可能初始化过的tlb全清零,然后 ...
- javascript中的继承方法
从Javascript面向对象编程(二):构造函数的继承这里,可以看到详细的说明. 我只是将其中的例子做成html文件,便于调试罢了. 1. 构造函数绑定 <html> <head& ...
- 使用PHP实现请求响应和MySql访问
在iOS开发当中经常需要使用来自后台的数据,所以使用一种很简便的写后台的方法. 首先,安装XAMPP,这是一个集成好的阿帕奇+MySQL环境,点击按钮即可开启服务,不需要进行任何环境配置. 然后,开启 ...
- 应用程序正常初始化(0xc015002)失败解决方法
VS2005 sidebyside manifest error Microsoft.VC80.MFC Microsoft.VC80.CRT Microsoft.VC80.MFCLOC msvcr80 ...
- 使用Vitamio打造自己的Android万能播放器(7)——在线播放(下载视频)
前言 本章将实现非常实用的功能——下载在线视频.涉及到多线程.线程更新UI等技术,还需思考产品的设计,如何将新加的功能更好的融入到现有的产品中,并不是简单的加一个界面就行了,欢迎大家交流产品设计和技术 ...
- (转)130道ASP.NET面试题
130道ASP.NET面试题 转自http://blog.csdn.net/kingmax54212008/article/details/2021204 1. 简述 private. protect ...