Sharpen.FilePath.CreateNewFile C# (CSharp) Method

CreateNewFile() public method

public CreateNewFile ( ) : bool
return bool
		public bool CreateNewFile ()
		{
			try {
				File.Open (path, FileMode.CreateNew).Close ();
				return true;
			} catch {
				return false;
			}
		}

Usage Example

示例#1
0
		/// <exception cref="System.IO.IOException"></exception>
		public static void CopyFile(FilePath sourceFile, FilePath destFile)
		{
			if (!destFile.Exists())
			{
				destFile.CreateNewFile();
			}
			FileChannel source = null;
			FileChannel destination = null;
			try
			{
				source = new FileInputStream(sourceFile).GetChannel();
				destination = new FileOutputStream(destFile).GetChannel();
				destination.TransferFrom(source, 0, source.Size());
			}
			finally
			{
				if (source != null)
				{
					source.Close();
				}
				if (destination != null)
				{
					destination.Close();
				}
			}
		}
All Usage Examples Of Sharpen.FilePath::CreateNewFile