Click here to Skip to main content
15,902,447 members
Home / Discussions / C#
   

C#

 
GeneralRe: Building Assembly Pin
DISP-Jol12-Feb-07 6:42
DISP-Jol12-Feb-07 6:42 
GeneralRe: Building Assembly Pin
DISP-Jol12-Feb-07 8:24
DISP-Jol12-Feb-07 8:24 
GeneralRe: Building Assembly Pin
DISP-Jol13-Feb-07 11:13
DISP-Jol13-Feb-07 11:13 
AnswerRe: Building Assembly Pin
sysmaniax12-Feb-07 6:42
sysmaniax12-Feb-07 6:42 
QuestionCMYK in C# Pin
__DanC__12-Feb-07 4:08
__DanC__12-Feb-07 4:08 
QuestionWeb Services Pin
LCI12-Feb-07 3:58
LCI12-Feb-07 3:58 
AnswerRe: Web Services Pin
Stefan Troschuetz12-Feb-07 5:47
Stefan Troschuetz12-Feb-07 5:47 
QuestionUsing File.Move() with variables Pin
markymark8212-Feb-07 3:34
markymark8212-Feb-07 3:34 
Hi,

I am tring to use the File.Move function in my app but I cannot get it to work with variables as the source and destination strings.

Heres my code,
I have a couple of text fields supplying info for the source file path and want to use them to place th files found in the parent directory.

String ParentDir = textfield1.Text;
String ChildDir = textfield2.Text;
DirectoryInfo di = new DirectoryInfo(@"c:\"+ParentDir+@"\"+ChildDir+@"\");

foreach (FileInfo fileinfo in di.GetFiles())
{
String newdirectory = @"c:\"+ParentDir+@"\";
//new file name is same as one found
String newfilename = fileinfo.Name.ToString();
String Newdirandname = newdirectory + newfilename;

File.Move(di+fileinfo.Name, Newdirandname);
}

I am very new to C# .Net so please keep any suggestions simple (if they are!).
I am just getting the message that part of the file path cannot be found, but they all exist.
It seems to expect the destination file to already exist, which it won't until I have moved it there?

Any help would be appreciated, many thanks in advance

Mark
AnswerRe: Using File.Move() with variables [modified] Pin
Bekjong12-Feb-07 3:47
Bekjong12-Feb-07 3:47 
GeneralRe: Using File.Move() with variables Pin
althamda12-Feb-07 3:50
althamda12-Feb-07 3:50 
GeneralRe: Using File.Move() with variables Pin
Bekjong12-Feb-07 3:52
Bekjong12-Feb-07 3:52 
GeneralRe: Using File.Move() with variables Pin
markymark8212-Feb-07 4:06
markymark8212-Feb-07 4:06 
AnswerRe: Using File.Move() with variables Pin
althamda12-Feb-07 4:04
althamda12-Feb-07 4:04 
GeneralRe: Using File.Move() with variables Pin
__DanC__12-Feb-07 4:07
__DanC__12-Feb-07 4:07 
GeneralRe: Using File.Move() with variables Pin
markymark8212-Feb-07 4:07
markymark8212-Feb-07 4:07 
AnswerRe: Using File.Move() with variables Pin
lost in transition 12-Feb-07 4:13
lost in transition 12-Feb-07 4:13 
GeneralRe: Using File.Move() with variables Pin
__DanC__12-Feb-07 4:21
__DanC__12-Feb-07 4:21 
GeneralRe: Using File.Move() with variables Pin
markymark8212-Feb-07 4:24
markymark8212-Feb-07 4:24 
GeneralRe: Using File.Move() with variables Pin
markymark8212-Feb-07 4:43
markymark8212-Feb-07 4:43 
AnswerRe: Using File.Move() with variables Pin
Pete O'Hanlon12-Feb-07 4:44
mvePete O'Hanlon12-Feb-07 4:44 
QuestionOverriding Form.Dispose(bool disposing)... Pin
Shy Agam12-Feb-07 3:28
Shy Agam12-Feb-07 3:28 
AnswerRe: Overriding Form.Dispose(bool disposing)... Pin
Bekjong12-Feb-07 3:39
Bekjong12-Feb-07 3:39 
QuestionError while saving images through GDI+ Pin
Nitin198112-Feb-07 3:28
Nitin198112-Feb-07 3:28 
AnswerRe: Error while saving images through GDI+ Pin
Luc Pattyn12-Feb-07 6:07
sitebuilderLuc Pattyn12-Feb-07 6:07 
GeneralRe: Error while saving images through GDI+ Pin
Nitin198113-Feb-07 7:50
Nitin198113-Feb-07 7:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.