如何使用c#将jpeg移动到选定的文件夹路径? [英] how to move a jpeg into selected folder path using c# ?

查看:66
本文介绍了如何使用c#将jpeg移动到选定的文件夹路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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");
        }



我是c#.NET的新手


I am new to c#.NET

推荐答案

看看这里:< a href =http://msdn.microsoft.com/en-us/library/cc148994.aspx> File.Move方法() [ ^ ]

如何:复制,删除和移动文件和文件夹(C#编程指南) [ ^ ]
Have a look here: File.Move method()[^]
How to: Copy, Delete, and Move Files and Folders (C# Programming Guide)[^]


试试这个(假设问题出现在这部分你的代码)

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



你应该注意:

1. Directory.CreateDirectory()如果目录已存在则不会导致并发症。

2. Path.Combine()接受数组或多个参数。

3.您之前的代码无效因为你的条件之前有''!'',所以代码只有在目录不存在的情况下才会起作用。


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.


这篇关于如何使用c#将jpeg移动到选定的文件夹路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆