Я пытаюсь скопировать файл, чтобы создать резервную копию этого. Это происходит рекурсивно пару раз, но с тех пор, как я делал эту рекурсивную, эта ошибка выбрана.public void Scan(string path)
{
string[] libs = { "CHIP", "SOT", "SMC", "SOP", "SOJ", "QFP", "PLCC", "PLCC", "SINGLE", "SIP", "DIP", "CON", "ZIG", "BRG", "PAD", "FID" };
try
{
foreach (string lib in libs)
{
foreach (var filePath in Directory.EnumerateFiles(path, lib +".lib"))
{
//This is for debugging important in order to differ between used and unused libs
//Here i should create a new instance of a file class that way i can find the lib's back easyly
createBackup(filePath, txtBackup.Text);
}
}
foreach (var dir in Directory.EnumerateDirectories(path))
{
Scan(dir);
}
}
catch (UnauthorizedAccessException)
{
Console.WriteLine("Error: " + path);
}
}
public void createBackup(string filePath, string backUpLocation)
{
string fileToBackUp = filePath;
string fileName;
int lastBackSlash = filePath.LastIndexOf("\\") + 1;
string caption;
string message;
fileName = fileToBackUp.Substring(lastBackSlash, fileToBackUp.Length - lastBackSlash);
if (System.IO.File.Exists(backUpLocation + "\\" + fileName) && chk_overWriteAllBackups.IsChecked == false)
{
caption = "File already present!";
message = "Would you like to override the previous back-up that is present in this folder?";
MessageBoxButtons buttons = MessageBoxButtons.YesNo;
DialogResult result;
result = System.Windows.Forms.MessageBox.Show(message, caption, buttons);
if (result == System.Windows.Forms.DialogResult.Yes)
{
//Backup created in the selected folder and old backup is overwriten
//Add the name of the file to the array of backed up items
System.IO.File.Copy(filePath, backUpLocation + "\\" + fileName, true);
readFiles();
}
else
{
caption = "Are you sure?";
message = "No back-up will be created are you sure?";
result = System.Windows.Forms.MessageBox.Show(message, caption, buttons);
if (result == System.Windows.Forms.DialogResult.Yes)
{
//Continue without backups
readFiles();
}
else
{
caption = "Select diffrent back-up location?";
message = "Would you like to select a new back-up location?";
result = System.Windows.Forms.MessageBox.Show(message, caption, buttons);
if (result == System.Windows.Forms.DialogResult.Yes)
{
//Return the user so a new back-up location can be selected
return;
}
else
{
//Continue without backups
readFiles();
}
}
}
}
else
{
try
{
Error-> System.IO.File.Copy(filePath, backUpLocation + "\\" + fileName, true);
}
catch (IOException e)
{
caption = "Error";
message = e.ToString();
System.Windows.Forms.MessageBox.Show(message, caption);
}
}
readFiles();
}
< /code>
Полная ошибка: < /p>
system.io.ioexception: de ingang ongeldig. \ r \ n \ r \ n bij
system.io.__error.winioerrou System.io.file.internalcopy (String
SourceFilename, String destfilename, Boolean Overwrite, Boolean
checkhost) \ r \ n bij System.io.file.copy (String SourceFilename, String
destfilenam FilePath, String Backuplocation)
in
c:lomasers\tomekjasinski\documents\hello_world\test\tomeStes>
Подробнее здесь: https://stackoverflow.com/questions/569 ... befullpath
Как исправить System.io .__ error.winioError (int32 ErrorCode, String может быть ⇐ C#
Место общения программистов C#
1756173938
Anonymous
Я пытаюсь скопировать файл, чтобы создать резервную копию этого. Это происходит рекурсивно пару раз, но с тех пор, как я делал эту рекурсивную, эта ошибка выбрана.public void Scan(string path)
{
string[] libs = { "CHIP", "SOT", "SMC", "SOP", "SOJ", "QFP", "PLCC", "PLCC", "SINGLE", "SIP", "DIP", "CON", "ZIG", "BRG", "PAD", "FID" };
try
{
foreach (string lib in libs)
{
foreach (var filePath in Directory.EnumerateFiles(path, lib +".lib"))
{
//This is for debugging important in order to differ between used and unused libs
//Here i should create a new instance of a file class that way i can find the lib's back easyly
createBackup(filePath, txtBackup.Text);
}
}
foreach (var dir in Directory.EnumerateDirectories(path))
{
Scan(dir);
}
}
catch (UnauthorizedAccessException)
{
Console.WriteLine("Error: " + path);
}
}
public void createBackup(string filePath, string backUpLocation)
{
string fileToBackUp = filePath;
string fileName;
int lastBackSlash = filePath.LastIndexOf("\\") + 1;
string caption;
string message;
fileName = fileToBackUp.Substring(lastBackSlash, fileToBackUp.Length - lastBackSlash);
if (System.IO.File.Exists(backUpLocation + "\\" + fileName) && chk_overWriteAllBackups.IsChecked == false)
{
caption = "File already present!";
message = "Would you like to override the previous back-up that is present in this folder?";
MessageBoxButtons buttons = MessageBoxButtons.YesNo;
DialogResult result;
result = System.Windows.Forms.MessageBox.Show(message, caption, buttons);
if (result == System.Windows.Forms.DialogResult.Yes)
{
//Backup created in the selected folder and old backup is overwriten
//Add the name of the file to the array of backed up items
System.IO.File.Copy(filePath, backUpLocation + "\\" + fileName, true);
readFiles();
}
else
{
caption = "Are you sure?";
message = "No back-up will be created are you sure?";
result = System.Windows.Forms.MessageBox.Show(message, caption, buttons);
if (result == System.Windows.Forms.DialogResult.Yes)
{
//Continue without backups
readFiles();
}
else
{
caption = "Select diffrent back-up location?";
message = "Would you like to select a new back-up location?";
result = System.Windows.Forms.MessageBox.Show(message, caption, buttons);
if (result == System.Windows.Forms.DialogResult.Yes)
{
//Return the user so a new back-up location can be selected
return;
}
else
{
//Continue without backups
readFiles();
}
}
}
}
else
{
try
{
Error-> System.IO.File.Copy(filePath, backUpLocation + "\\" + fileName, true);
}
catch (IOException e)
{
caption = "Error";
message = e.ToString();
System.Windows.Forms.MessageBox.Show(message, caption);
}
}
readFiles();
}
< /code>
Полная ошибка: < /p>
system.io.ioexception: de ingang ongeldig. \ r \ n \ r \ n bij
system.io.__error.winioerrou System.io.file.internalcopy (String
SourceFilename, String destfilename, Boolean Overwrite, Boolean
checkhost) \ r \ n bij System.io.file.copy (String SourceFilename, String
destfilenam FilePath, String Backuplocation)
in
c:lomasers\tomekjasinski\documents\hello_world\test\tomeStes>
Подробнее здесь: [url]https://stackoverflow.com/questions/56936947/how-to-fix-system-io-error-winioerrorint32-errorcode-string-maybefullpath[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия