-1-
-2-
====================
قائمة الملفات
===================
كورس Windows Desktop Applications in c sharp مهندس بديع موسى راجى
https://www.youtube.com/playlist?list=PLMmy9Ec9B98yVy2t1hE3t4t1zKAxAvpkW
==========
قائمة الملفات
===================
تعلم لغة c sharp من البداية الى الاحتراف مهندس بديع موسى راجى
https://www.youtube.com/playlist?list=PLMmy9Ec9B98xzr_x2vafMGx9_gCIkZhM6
======================
قائمة الملفات
===============
كورس Object-oriented programming C Sharp مهندس بديع موسى راجى
https://www.youtube.com/playlist?list=PLMmy9Ec9B98yRqBvoBB2Wi3mNro5DDdOL
=======================
قائمة الملفات
===============
Database Analysis and design Full course - ERD schema مهندس بديع موسى راجى
https://www.youtube.com/playlist?list=PLMmy9Ec9B98zl-h_NvnQAs8BW8QRMIw-P
======================
قائمة الملفات
===============
تعلم باحتراف MS SQL server 2019 مهندس بديع موسى راجى
https://www.youtube.com/playlist?list=PLMmy9Ec9B98zuTzQXSZYomkE-RLntASLB
=================
الموقع
https://course-7.blogspot.com/
============================
What is FileInfo?
FileInfo used for typical operations such as copying, moving, renaming, creating, opening, deleting and appending to files.
It uses StreamWriter class to write data and StreamReader class to read data to the file.
It is sealed class so we cannot be inherited.
FileInfo class Provides Methods and Properties.
FileInfo Parent class and namespace
FileInfo class is a System.IO namespace.
FileInfo’s Parent class is a FileSystemInfo.
FileInfo Properties
Attributes
CreationTime
CreationTime Utc
Directory
DirectoryName
Exists
Extension
FullName
IsReadOnly
LastAccessTime
LastAccessTimeUtc
LastWriteTime
LastWriteTimeUtc
Length
Name
FileInfo Methods
AppendText()
CopyTo()
Create()
CreateText()
Decrypt()
Delete()
Encrypt()
GetAccessControl()
GetLifetimeServices()
Replace()
InitializeLifetimeService()
MemberWiseClone()
MoveTo()
Open()
OpenRead()
OpenText()
OpenWrite()
Refresh()
Code for FileInfo class demo :
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FileInfoDemo
{
class Program
{
static void Main(string[] args)
{
//Create Method
FileInfo fi = new FileInfo(@"E:/file/MyTestFile.txt");
FileStream fs = fi.Create();
Console.WriteLine("File Has been Created");
//CreateText Method
FileInfo fi = new FileInfo(@"E:/file/MyTestFile.txt");
StreamWriter str = fi.CreateText();
str.WriteLine("Ankpro");
Console.WriteLine("File has been Created with text");
str.Close();
//Delete Method
FileInfo fi = new FileInfo(@"E:/file/MyTestFile.txt");
fi.Delete();
Console.WriteLine("File has been deleted");
//copy method
string path = @"E:/file/MyTestFile.txt";
string path2 = @"E:/copy/MyTestFile.txt";
FileInfo f1 = new FileInfo(path);
FileInfo f2 = new FileInfo(path2);
f1.CopyTo(path2);
Console.WriteLine("{0} was copied to {1}." , path, path2);
// move method
string path = @"E:/file/Move.txt";
string path2 = @"E:/copy/Move.txt";
FileInfo f1 = new FileInfo(path);
FileInfo f2 = new FileInfo(path2);
f1.MoveTo(path2);
Console.WriteLine("{0} was copied to {1}.", path, path2);
//opentext method
FileInfo fi = new FileInfo(@"E:/file/MyTestFile.txt");
StreamReader sr = fi.OpenText();
string s = "";
while((s=sr.ReadLine())!=null)
{
Console.WriteLine(s);
}
FileInfo fi = new FileInfo(@"E:/file/MyTestFile.txt");
Console.WriteLine("File name is {0}", fi.Name);
Console.WriteLine("File Creation Time is {0}", fi.CreationTime);
Console.WriteLine("File LastAccess Time is {0}", fi.LastAccessTime);
Console.WriteLine("File Length is {0}", fi.Length +"bytes");
}
}
}
-3-
-4-