im using a code to copy the files from the database of server PC. so im accessing that server PC through IP address but it is giving me error and not copying the fil开发者_如何学编程es in the folder of my PC (client PC) this is my code that im using...can u tell me where im wrong??
the file path is given on my listview in winform..
public string RecordingFileCopy(string recordpath,string ipadd)
{
string strFinalPath;
strFinalPath = String.Format("\\{0}'{1}'",ipadd,recordpath);
return strFinalPath;
}
on button click event....
{
try
{
foreach (ListViewItem item in listView1.Items)
{
string sourceFile = item.SubItems[5].Text;
RecordingFileCopy(sourceFile,"10.0.4.123");
File.Copy(sourceFile, Path.Combine(@"E:\name\MyDir", Path.GetFileName(sourceFile)));
}
}
catch
{
MessageBox.Show("Files are not copied to folder", _strMsg, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
If your database is is currently attached to the database server, e.g. SQL Server is attached to the .mdf file you want to copy, then file is locked and you won't be able to copy it. You'll first need to detach from the target database.
精彩评论