Click here to Skip to main content
15,900,258 members
Home / Discussions / C#
   

C#

 
GeneralRe: Please give me the source code for REMINDER in ASP.NET with C# Pin
Paul Conrad5-Dec-08 10:44
professionalPaul Conrad5-Dec-08 10:44 
GeneralRe: Please give me the source code for REMINDER in ASP.NET with C# PinPopular
Kristian Sixhøj5-Dec-08 9:26
Kristian Sixhøj5-Dec-08 9:26 
GeneralRe: Please give me the source code for REMINDER in ASP.NET with C# Pin
Paul Conrad5-Dec-08 10:45
professionalPaul Conrad5-Dec-08 10:45 
GeneralRe: Please give me the source code for REMINDER in ASP.NET with C# PinPopular
Christian Graus5-Dec-08 10:01
protectorChristian Graus5-Dec-08 10:01 
GeneralRe: Please give me the source code for REMINDER in ASP.NET with C# Pin
Paul Conrad5-Dec-08 10:45
professionalPaul Conrad5-Dec-08 10:45 
QuestionHow to attach and detach file from a filestream Pin
s196675m5-Dec-08 8:47
s196675m5-Dec-08 8:47 
GeneralRe: How to attach and detach file from a filestream Pin
Luc Pattyn5-Dec-08 9:27
sitebuilderLuc Pattyn5-Dec-08 9:27 
QuestionCopy Files and Maintain Directory Structure Pin
Michael Fritzius5-Dec-08 8:33
professionalMichael Fritzius5-Dec-08 8:33 
Hi All,

Sorry about the rapid-fire questions, but I'm making a ton of progress with my project. Thank you to everyone who's helped me so far, and thanks in general to CodeProject--this site is heavily visited when I need something done.

For my next question, I need to know how to copy a file from one location to another while still keeping the same directory structure. An example would be:

c:\foo\bar\123.txt ---copy---> c:\copy\foo\bar\123.txt

I get an exception saying part of the path couldn't be found.

I can get to the original file just fine, so it exists where strOrigFile says it does. The destination path looks all right--the only difference being the highest parent directory being "Symbiosys_Backup" instead of "Files".

But I don't know what to do about this exception.

Do I have to recursively create directories as I go, or is there a ninja-sneaky way of pulling this off without pulling my hair out?

Code that I have is below.

private void button4_Click(object sender, EventArgs e)
        {
            // Get the strings from the textboxes
            string strOrigFile = "Files\\testfile.txt";
            string strDestFile = "C:\\Symbiosys_Backup\\" + (System.IO.Path.GetFullPath(strOrigFile)).Replace(@"C:\", @"");

            // Get the filename only
            string strFileName = System.IO.Path.GetFileName(strOrigFile);

            // Determine the full destination path including filename
            //string strDestFile = System.IO.Path.Combine(strDestLoc, strFileName);

            // Copy the file
            MessageBox.Show("Original File: " + strOrigFile + "\r\nDestination File: " + strDestFile);
            System.IO.File.Copy(strOrigFile, strDestFile, true);
        }


Thanka you,
Michael Fritzius
GeneralRe: Copy Files and Maintain Directory Structure Pin
Luc Pattyn5-Dec-08 9:07
sitebuilderLuc Pattyn5-Dec-08 9:07 
GeneralRe: Copy Files and Maintain Directory Structure Pin
Michael Fritzius5-Dec-08 9:23
professionalMichael Fritzius5-Dec-08 9:23 
QuestionDeploying MySQL as backend for C# Pin
bigphildogg865-Dec-08 7:45
bigphildogg865-Dec-08 7:45 
AnswerRe: Deploying MySQL as backend for C# Pin
Adam Maras5-Dec-08 8:28
Adam Maras5-Dec-08 8:28 
AnswerRe: Deploying MySQL as backend for C# Pin
Wendelius5-Dec-08 8:29
mentorWendelius5-Dec-08 8:29 
QuestionHelp decoding base_64+GZipped string. Pin
Zeokat5-Dec-08 7:41
Zeokat5-Dec-08 7:41 
AnswerRe: Help decoding base_64+GZipped string. [modified] Pin
Guffa5-Dec-08 14:09
Guffa5-Dec-08 14:09 
GeneralRe: Help decoding base_64+GZipped string. Pin
Zeokat5-Dec-08 15:51
Zeokat5-Dec-08 15:51 
GeneralRe: Help decoding base_64+GZipped string. Pin
Zeokat6-Dec-08 4:37
Zeokat6-Dec-08 4:37 
QuestionGet the frequency of a audio-sound Pin
softwarejaeger5-Dec-08 7:33
softwarejaeger5-Dec-08 7:33 
QuestionSqlBulkCopy question Pin
Jon Stroh5-Dec-08 7:19
Jon Stroh5-Dec-08 7:19 
AnswerRe: SqlBulkCopy question Pin
Wendelius5-Dec-08 8:37
mentorWendelius5-Dec-08 8:37 
Questionobject type [modified] Pin
nlowdon5-Dec-08 6:40
nlowdon5-Dec-08 6:40 
AnswerRe: object type Pin
Thomas Weller5-Dec-08 7:05
Thomas Weller5-Dec-08 7:05 
GeneralRe: object type Pin
nlowdon5-Dec-08 8:30
nlowdon5-Dec-08 8:30 
GeneralRe: object type Pin
Thomas Weller6-Dec-08 2:17
Thomas Weller6-Dec-08 2:17 
AnswerRe: object type Pin
Le centriste5-Dec-08 7:07
Le centriste5-Dec-08 7:07 

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.