C # text _ Folder Actions

1 we used the File class can be used to look at the code of some operations on files below.

 

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp5
{
class Program
{
static void Main(string[] args)
{

// File copying text 
byte [] s = File.ReadAllBytes (@ "C: \ Users \ Administrator \ Desktop \ 666.txt"); // Converts the specified file into a binary number into Byte array (fill is address specified file)
File.WriteAllBytes (@ "C: \ the Users \ Administrator \ Desktop \ 888.txt", S); // will be written to the specified file (copy of meaning) designated path press Ctrl + F5 later on We can see a 888. Text txt inside the content and specify the file as

// File image manipulation can copy files can be written to this by converting binary form either the picture or Exicl

// Here is the picture into a binary byte array and then he receives written to the specified address, you can get 333.png picture
byte [] p = File.ReadAllBytes (@ "C: \ Users \ Administrator \ Desktop \ 22.png" );
File.WriteAllBytes (@ "C: \ the Users \ Administrator \ Desktop \ 333.png", the p-);

 

// Stream flow in the manner of copying files
the FileStream = new new the Read the FileStream (@ "C: \ the Users \ Administrator \ Desktop \ 22.png", FileMode.Open);
the FileStream = new new weirt the FileStream (@ "C: \ the Users \ Administrator \ Desktop \ 66.png ", FileMode.CreateNew);
byte [] = REA new new byte [1024];
the while (to true)
{
int length = read.Read (REA, 0,1024);
IF (length == 0)
{
BREAK;
}
weirt.Write (REA, 0, length);
}
read.Close (); // file to complete the operation must be shut down stream, otherwise continuing to the next file operation is displayed, this flow being used
weirt. Close ();

}
}
}

Guess you like

Origin www.cnblogs.com/LanPeng/p/10932744.html