Click here to Skip to main content
15,919,245 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
I want to append a new directory to destination folder which is a network path

My network path is \\nup-234\TP\DD300\OLD
To this I need to append current year and month which means
\\nup-234\TP\DD300\OLD\2016\10 and then move the file to this.

What I have tried:

C#
if (File.Exists(oldpathname + "\\" + filename))
                   {
                       string s = newpathname + "\\" + filename;
                       File.Move(oldpathname + "\\" + filename, newpathname + "\\" + filename);

                   }
Posted
Updated 13-Oct-16 5:59am
v2
Comments
[no name] 13-Oct-16 9:27am    
And? Did you maybe have a question you wanted to ask? Did you maybe forget to provide a description of any kind of a problem?
ZurdoDev 13-Oct-16 10:42am    
What is the question?

1 solution

Use System.IO.Directory.CreateDirectory(newpathname) before the Move.

You don't need to check if it exists first, all directories specified in path are created if don't exists, if the directory already exists, CreateDirectory does nothing.

I hope I have answeres your "hidden" question.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900