Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added 2.Task3 #7

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
added 2.Task3
Zikirillo2002 committed Jun 11, 2023
commit cc9bf20b30f94a0bde6359ce21183b4ec20b38c2
35 changes: 34 additions & 1 deletion HomeworksDircAndFile/Program.cs
Original file line number Diff line number Diff line change
@@ -4,7 +4,40 @@ internal class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
Console.Write("Fayl manzilini kiriting" +
"(Misol : D:\\papka nomi..\\Fayl nomi.docx) : ");

string path = Console.ReadLine();

Console.Write(" Nusxani ko'chirmoqchi bo'lgan" +
" fayl manzilini kiriting" +
"(Misol : D:\\papka nomi..\\) : ");

string newPath = Console.ReadLine();

CopyToFiels(path, newPath);
}

static void CopyToFiels(string path, string newPath)
{
var fileinfo = new FileInfo(path);

if(!File.Exists(newPath))
{
File.Create(newPath);
}

if(fileinfo.Exists)
{
fileinfo.CopyTo( newPath,true);

Console.WriteLine($" {path} fayldan {newPath} " +
$"faylga nusxa ko'chirildi.");
}
else
{
Console.WriteLine($"Bunday fayl {path} mavjud emas");
}
}
}
}