How to Create Code For Cut,Copy,Paste in c# ?

Posted by Sabarimahesh under C# on 3/19/2012 | Points: 10 | Views : 7294 | Status : [Member] | Replies : 11
For Example we are using Windows Os

We Will Copy the folder.. then we will paste

If Folder name is Rs.... after the folder pasted Rs Renamed as Rs1

We Will Cut the folder.. then we will paste

If Folder name is Rs.... after the folder pasted Rs Renamed as Rs

The Rs Folder Changed The location...

Like that

How Create a Floder?
How to Write a Code for Cut ,Copy &Paste?

If any body Know about this please help ME..

Life is a Race
Thanks & Regards
By
Sabari Mahesh P M



Responses

Posted by: Sabarimahesh on: 3/19/2012 [Member] Bronze | Points: 25

Up
0
Down
Sksamantaray

How to create A Specific Floder

Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

Sabarimahesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naraayanan on: 3/19/2012 [Member] Starter | Points: 25

Up
0
Down
Hi
Create a Directory : Directory.CreateDirectory(FolderName)
Move : Directory.Move(from ,To) --- Like a Cut ,Copy Paste
The Three Functions are in one Function.


Regards,
Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
http://abaprocker.blogspot.com/

Sabarimahesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sabarimahesh on: 3/20/2012 [Member] Bronze | Points: 25

Up
0
Down
Naraayanan

I try To Do It in mY Own Application

Can You Give idea About it

Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

Sabarimahesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajni.Shekhar on: 3/20/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi,
Narayana is right. You can use Directory.CreateDirectory(folderName)// give name of folder here
then u can use move method of directory class irectory.Move(fromlocation, tolocation);

even you can refer

http://msdn.microsoft.com/en-us/library/system.io.directory.createdirectory(v=vs.71).aspx

Thanks,
Rajni Shekhar

Sabarimahesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naraayanan on: 3/20/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,
Please try this ,
Declaration Part
  public static bool result;

 string inputFolder = @"E:\Test";

string outputFolder = @"E:\Test1\";
bool result = createPasteFolder(inputFolder, outputFolder);
if (result)
{
MessageBox.Show("Successed");
}
else
{
MessageBox.Show("Failure");
}

        #region Create and Paste a Folder into One location to another

public static bool createPasteFolder(string fldName, string transferfld)
{

if (!System.IO.Directory.Exists(fldName))
{
System.IO.Directory.CreateDirectory(fldName);
}
else
{
if (!System.IO.Directory.Exists(transferfld))
{
string lastPath = fldName.Split('\\').Last();
System.IO.Directory.CreateDirectory(transferfld);
// System.IO.Directory.Delete(fldName);
System.IO.Directory.CreateDirectory(transferfld + @"\" + lastPath);
result = true;
}
else
{
System.IO.Directory.CreateDirectory(transferfld);
string lastPath = fldName.Split('\\').Last();
// System.IO.Directory.Delete(fldName);
System.IO.Directory.CreateDirectory(transferfld + @"\" + lastPath);
result = true;
}
}
return result;
}
#endregion Create and Paste a Folder into One location to another



Regards,
Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
http://abaprocker.blogspot.com/

Sabarimahesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sabarimahesh on: 3/21/2012 [Member] Bronze | Points: 25

Up
0
Down
Naraayanan : That Code right
Please See that attachments

Becoz This Is My requirement


 Download source file

Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

Sabarimahesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naraayanan on: 3/22/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,
I saw your file.Could you please explain your Query. as u said in the file. User clicks the Create Folder Button, Folder should be create in this Application. .What is mean by this Application? .I don't know your Application flow . So Please explain it.


Regards,
Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
http://abaprocker.blogspot.com/

Sabarimahesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sabarimahesh on: 3/22/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi,

"This Application " In the sense my application..

I Going to Create a Static Website..

in that ,When Multiple user using the website..

They will keep The File in the Website By Creating Folder.

You replied the Code..That will Create The folder in Our System Or Our Hard-disk ..

But i need To Create as Like a Folder in My websit


Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

Sabarimahesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rajni.Shekhar on: 3/22/2012 [Member] Bronze | Points: 25

Up
0
Down
Hi,

In Naraayanan code change folder path:

Ex:

string outputFolder = @"~/AppFiles/"; //folder name



Thanks,
Rajni Shekhar

Sabarimahesh, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sabarimahesh on: 3/22/2012 [Member] Bronze | Points: 25

Up
0
Down
Rajni.Shekhar
i'll try it and inform you


Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

Sabarimahesh, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response