Как исправить System.io .__ error.winioError (int32 ErrorCode, String может бытьC#

Место общения программистов C#
Ответить
Anonymous
 Как исправить System.io .__ error.winioError (int32 ErrorCode, String может быть

Сообщение 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>

Подробнее здесь: https://stackoverflow.com/questions/569 ... befullpath
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C#»