Hello,
I have been struggling quite a bit with a problem that cannot possibly
be this difficult to get past.
The full scenario, is that I want to get a file from our Visual
SourceSafe database, run a parser on it (translates an SQL dialect)
and check it into another location.
Now the SourceSafe and translation bit of all this works like a charm,
but handling the temp files don't. The basic structure (first cut)
looks like this:
private void button3_Click(object sender, EventArgs e)
{
IVSSItem itemSybase = dataBase.get_VSSItem(comboSybasePath.Text,
false);
IVSSItem itemSQL = dataBase.get_VSSItem(comboSQLPath.Text, false);
string pathSybase = Path.GetTempFileName();
string pathSQL = Path.GetTempFileName();
FileInfo fileSybase = new FileInfo(pathSybase);
FileInfo fileSQL = new FileInfo(pathSQL);
try
{
itemSybase.Get(ref pathSybase,
(int)(VSSFlags.VSSFLAG_REPREPLACE |
VSSFlags.VSSFLAG_FORCEDIRYES));
itemSQL.Checkout("Automatic conversion from Sybase", pathSQL,
(int)(VSSFlags.VSSFLAG_REPREPLACE |
VSSFlags.VSSFLAG_FORCEDIRYES));
try
{
ConvertStoredProc(fileSybase, fileSQL);
itemSQL.Checkin("Automatic conversion from Sybase",
pathSQL, 0);
}
catch
{
itemSQL.UndoCheckout(pathSQL, 0);
throw;
}
}
finally
{
fileSybase.Delete();
fileSQL.Delete();
}
}
Essentially, I get the temp file names with Path.GetTempFileName() and
let SourceSafe overwrite the first file. I then use FileInfo objects
to process the source text, write the destination file and finally
delete both files once the destination file has been checked into
SourceSafe.
What perplexes me no end, is the fact that I can create the temporary
files without a hitch, but deleting them again causes a
SecurityException to be thrown. Why can I not delete a file that I was
able to create?
I then tried to specify FileIOPermission on my application, but the
same is then used on the imported assembly for SourceSafe. And since I
don't actually want to access anything other than the temp folder, I
really want to specify Path.GetTempPath() as the path to get
permission to - where do I do that?
Finally, I thought I would use isolated storage, but again ran into
trouble. Unless I missed it somehow, you cannot actually get the name
of the file path you are working with - which means that I cannot
specify that path for SourceSafe to use!
Right now, it almost seems like the most reliable way of doing this
will be to simply leave the temp files, but that is messy.
Any ideas?
Cobus Kruger