I'm using the SharpSVN .NET library. This exception only occurs when adding a file, but not adding a folder. Why would that be?
Can't open file 'D:\FOLDER\FILE.xls': The process cannot access the file because it is being used by another process.
Here is the code. It contains the folder logic and the file logic.
SvnUpdateArgs updateArgs2 = new SvnUpdateArgs();
updateArgs2.Depth = SvnDepth.Empty;
client.Update("D:\FOLDER", updateArgs2);
if (!Directory.Exists("D:\FOLDER"))
{
System.IO.Directory.CreateDirectory("D:\FOLDER");
SvnAddArgs addArgs1 = new SvnAddArgs();
addArgs1.Depth = SvnDepth.Empty;
client.Add("D:\FOLDER", addArgs1);
SvnCommitArgs commitArgs1 = new SvnCommitArgs();
commitArgs1.LogMessage = GeneralService.GetCurrentUserWindowsLogin();
client.Commit("D:\FOLDER", commitArgs1);
}
// update if exists, otherwise add it to working copy if it does not exist
SvnUpdateArgs updateArgs3 = new SvnUpdateArgs();
updateArgs3.Depth = SvnDepth.Empty;
client.Update("D:\FOLDER\FILE.xls", updateArgs3);
if (!File.Exists("D:\FOLDER\FILE.xls"))
{
System.IO.File.Create("D:\FOLDER\FILE.xls");
SvnAddArgs addArgs1 = new SvnAddArgs();
addArgs1.Depth = SvnDepth.Empty;
client.Add("D:\FOLDER\FILE.xls", addArgs1);
SvnCommitArgs commitArgs1 = new SvnCommitArgs();
commitArgs1.LogMessage = GeneralService.GetCurrentUserWindowsLogin();
client.Commit("D:\FOLDER\FILE.xls", commitArgs1);
}
When you use system.io.file.create
it create an instance os system.io.stream coz it is a shared function.I suppose that you can fix it in a simple manner like this one.
Dim F As System.IO.FileStream = System.IO.File.Create("piipo")
''release the stream
F.Close()