C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




How to move a File to new location


Posted Date: 05 Jun 2008    Resource Type: Code Snippets    Category: Active Directory
Author: Payal JainMember Level: Gold    
Rating: Points: 5



introduction


This code sample will help you to move a file to new location even if the new location does not exist

namespace


Namespace used for this is Microsoft.VisualBasic.MyServices which will be imported to your
application using:


using Microsoft.VisualBasic.MyServices;


Referrences to be added to your project


You may need to add reference to microsoft.visualbasic.dll to your project.

code and its description



When we try to copy a file using File.Move method it is required that the destination should exist. If it doesn't, then DirectoryNotFoundException is thrown. You can overcome this problem using filesystem object as follows:




FileSystemProxy FileSystem = new Microsoft.VisualBasic.Devices.Computer().FileSystem;
FileSystem.MoveFile(@"C:\myfolder\myFile.txt",@"D:\yourFoldr" );

FileSystem = null;



In the above example we try to move myFile.txt to a new folder (not yet created) in d:\




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Move Files to a non-exisiting Destinations  .  Move files in C#  .  Move a File in C#  .  Move a File  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: How to reset the drop down list using java script
Previous Resource: How to rename a directory
Return to Discussion Resource Index
Post New Resource
Category: Active Directory


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design


Contact Us    Privacy Policy    Terms Of Use