private void tsbImport_Click(object sender, EventArgs e)
{
if (_fs == null)
{
return;
}
var ofd = new OpenFileDialog();
ofd.Title = "Import...";
if (_lastImportExportPath != null)
{
ofd.InitialDirectory = _lastImportExportPath;
}
ofd.CheckFileExists = true;
ofd.CheckPathExists = true;
ofd.Multiselect = true;
if (ofd.ShowDialog() == DialogResult.OK)
{
_lastImportExportPath = IODirectory.GetParent(ofd.FileName).FullName;
List <string> _invalidFiles = new List <string>();
using (new WaitCursor(this))
{
for (var i = 0; i < ofd.FileNames.Length; i++)
{
var safename = Path.GetFileName(ofd.FileNames[i]);
File file = FindFileByName(safename);
if (file == null)
{
_invalidFiles.Add(safename);
}
else
{
byte[] data = IOFile.ReadAllBytes(ofd.FileNames[i]);
file.SetData(data);
}
}
}
if (_invalidFiles.Count > 0)
{
var sb = new StringBuilder();
foreach (var s in _invalidFiles)
{
sb.Append(" " + s + "\n");
}
MessageBox.Show("The following files were not found in the archive to be replaced:\n\n" + sb +
"\nPlease note that you can not add new files, only replace existing ones. The files must be named exactly " +
"as they are in the archive.", "Import", MessageBoxButtons.OK,
MessageBoxIcon.Exclamation);
}
PopulateListView();
}
}