Now what i need is to replace this picture and override it. The first thing i do is copy it to a new location (becuase i dont want to loose it)
1) i find if theres a picture for the user "eva" in the designated path .
Expand|Select|Wrap|Line Numbers
- String[] files = Directory.GetFiles(user_pic_path);
- if (files.Count<String>() > 0)
- {
- FileInfo _info = new FileInfo(files[0]);
- bool found = false;
- foreach (String _file in files)
- {
- _info = new FileInfo(_file);
- if (_info.Name.Equals(_peer_name + _info.Extension))
- {
- found = true;
- _fpath = _info.FullName;
- break;
- }
- }
altho i made sure to remove it from any other user before attempting to move it .
Expand|Select|Wrap|Line Numbers
- PeerContents updated_contents = getPeerContents(_peer_name); ;
- updated_contents.img = null;
- picbox_peer.Image = null;
- 3) as i was saying if it was found it gets copied to a new location
- if (found)
- {
- String files_path = Path.Combine(received_files_path, _info.Name);
- overrideOk = false;
- int i = 0;
- String ext = _info.Extension;
- String nm = _info.Name;
- _info = null;
- while (!overrideOk)
- {
- try
- {
- File.Copy(_fpath,files_path,false);
- overrideOk = true;
- }
- catch (Exception es)
- {
- i++;
- String f_name = nm.Substring(0,nm.Length - ext.Length);
- files_path = Path.Combine(received_files_path, f_name + "(" + i + ")" + ext);
- }
- }
- }
with override set to true , at this point i get the same System.IO.Exception claming that it is in use some by anouther process ( IT AINT! ..as far as i can tell )
..it wont let me delete it for the same reason...
Expand|Select|Wrap|Line Numbers
- String fileName = openFileDialog1.FileName;
- FileInfo new_info = new FileInfo(fileName);
- new_path = Path.Combine(user_pic_path,_peer_name + new_info.Extension);
- overrideOk = false;
- while (!overrideOk)
- {
- try
- {
- File.Copy(fileName, new_path, true);
- overrideOk = true;
- }
- catch (Exception es)
- {
- File.Delete(new_path);
- }
- }
if any one can think of the reason or knows how i can check what process holds the file,it would be most helpfull