Click here to Skip to main content
15,909,199 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
C#
if (textBox1.Text != "";)
{
    if (!Directory.Exists(textBox1.Text))
    {
        Directory.CreateDirectory(Path.Combine(textBox1.Text));
       
       
            File.Move(filetran, textBox1.Text);// i am struggle here..

        }
        catch (Exception e1)
        {
            MessageBox.Show(e1 + "error");
        }

I am new to c#.NET
Posted
v2

Try this (assuming the problem is in this part of your code)
C#
Directory.CreateDirectory(textbox1.Text);
File.Move(filetran, textbox1.Text);

You should note that:
1. Directory.CreateDirectory() causes no complications if the directory already exists.
2. Path.Combine() takes either an array or more than one argument.
3. Your previous code was doing nothing as you had a '!' before your condition, thus the code only acted if the directory did not exist.
 
Share this answer
 
v2

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