I am writing an simple application that will delete a file/directory. The application recives the target file as an argument. I have also put a shortcut in the W Explorer contextual menu, via Shell registry subkey of the folder entry
in the HKEY_CLASSES_ROOT.
@="Wipe it ..."
If a launch the program from a shell with an filename/folder as an argument it does it's job.
But if the program is launched via the option in the Explorer menu and the selected targer is a folder (with a simple file it works), then the deleting fails with the exception " ... file being used by another process". It seems that the program keeps an open handle on the directory. The delete operation is made via Directory.Delete() ( tried also working with DirectoryInfo ...same result).
Any one has any idea how can I get past this ?
LATER EDIT : I managed to track the problem after all. Simple stuff really, but forgot about it. Windows set the current directory for the program was set to be the target directory, so a simple change of the current directory was enough to get the program going.
I am trying to create an application that simply starts listening on a specific port number on the local machine, and writes all data received to a text box on the form. There will be a 3rd party application that is sending data th my IP address on a specific port number.
From what ive been reading, maybe I should use a TCPListener but Im not sure where to start.
private void cmdGetTrades_Click(object sender, EventArgs e)
dsXML.Clear(); // should already be defined else define it here
// allowing user to select file else you can directly hard
// code the file name
openFileDialog1.Filter = "XML Files|*.xml";
openFileDialog1.Title = "Select SWAPs trades' XML file";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
grdTrades.AutoGenerateColumns = true;
grdTrades.DataSource = dsXML;
grdTrades.DataMember = "trade";
I am using this so it certainly works! Hope that helps you.