Senior & Expert .Net Developers Discussion Forum by Nyros Technologies

HIRE .Net Expert Developers Programmers Coders From India
Ruby on Rails PHP .Net Developers Community, Nyros Technologies, Kakinada
 
Log in  or IF not a member please REGISTER
Username:
Password:   


Keyword
Log in | Profile 

How to create Folder in FTP site in Windows Application?

 
Post new topic   Reply to topic    Senior & Expert .Net Developers Discussion Forum by Nyros Technologies Index -> Programming with C#
View previous topic :: View next topic  
Author Message
suraj



Joined: 27 Aug 2007
Posts: 145

PostPosted: Tue Feb 16, 2010 7:30 am    Post subject: How to create Folder in FTP site in Windows Application? Reply with quote

Hi,

I am developing windows application for Creating Folder/Directory in FTP site.

How can i develop this task.Give me any help or suggestions...

Thanks inadvance...
Back to top
View user's profile Send private message
setty



Joined: 01 Apr 2009
Posts: 127
Location: GOLLAPROLU

PostPosted: Thu Feb 18, 2010 11:30 am    Post subject: Reply with quote

Hi suraj,

For creating Folder/Directory in FTP site you need to take one textBox control & Button control on to the form.

Add the following namespaces:

using System.IO;
using System.Net;

code under Button click event:

private void btn_Click(object sender, EventArgs e)
{
try
{
if (txtNewDir.Text.Trim() == "")
{
MessageBox.Show("You must enter Folder name.");

txtNewDir.BackColor = Color.Yellow;

return;
}
else
{
//Reset the background color
txtNewDir.BackColor = Color.White;
}

MakeDir(txtNewDir.Text.Trim());
}
catch
{
MessageBox.Show("Failed to create Folder.");
}
}


Code for method MakeDir():


private void MakeDir(string dirName)
{
FtpWebRequest reqFTP;
try
{
// dirName = name of the directory to create.
reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + ftpServerIP + "/" + dirName));
reqFTP.Method = WebRequestMethods.Ftp.MakeDirectory;
reqFTP.UseBinary = true;
reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword);
FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();
Stream ftpStream = response.GetResponseStream();

ftpStream.Close();
response.Close();

MessageBox.Show("Folder created successfully.");
txtNewDir.Text = "";
}
catch (Exception ex)
{
MessageBox.Show("Failed to create Folder.");
return;
}
}

Note:

Where ftpServerIP=here we need to pass HostName,UserId,Password.
_________________
Thanks & Regards
D.B.G.Setty
Software Engineer
NYROS TECHNOLOGIES
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Senior & Expert .Net Developers Discussion Forum by Nyros Technologies Index -> Programming with C#
Page 1 of 1


 latest topics 
 Topics   Replies   Author   Views   Last Post 
No new posts Is there any control like Gridview in WPF?
1 mukundh 12 Fri Jul 30, 2010 11:16 am
setty View latest post
No new posts Getting data from the other pages by sending a request.
1 pavani 8 Fri Jul 30, 2010 10:16 am
rajesh View latest post
No new posts Viewing or Reading an Assembly
0 sek 20 Mon Jul 26, 2010 10:33 am
sek View latest post
No new posts Multiple technologies to develop iPhone applications:
0 Ramya sree 21 Mon Jul 26, 2010 10:09 am
Ramya sree View latest post
No new posts What is the Difference Between CLR, CLS and CTS ?
1 pavani 27 Mon Jul 26, 2010 5:35 am
pavani View latest post
No new posts What is Android and How to install Android SDK.??
0 pavani 17 Mon Jul 26, 2010 4:46 am
pavani View latest post
No new posts Open-source libraries for iPhone application development:-
0 Teena 19 Sun Jul 25, 2010 8:17 am
Teena View latest post
No new posts Famous Mobile Sites:
1 kumar 17 Sun Jul 25, 2010 7:33 am
Teena View latest post
No new posts Introduction to PhoneGap framework
0 Dileep 24 Sun Jul 25, 2010 7:00 am
Dileep View latest post
No new posts Objective-C on Windows:
0 suraj 22 Sun Jul 25, 2010 6:16 am
suraj View latest post




Hire an expert .Net developer / coder / programmer or development team from India now!!

Other Forums : Ruby on Rails   ::   PHP   |   Free unlimited HTML CSS templates download

Nyros Technologies   |   Kakinada City Portal   |   Developers Blog   |   About .Net Experts   |   More