473,395 Members | 2,443 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to create directory on the FTP Server ?

Hi,
I have to create directories on the FTP server. I have tried directory.exists but it doesnt work.Any other way to create directory on the server.Please help me.
Aug 23 '08 #1
6 15187
joedeene
583 512MB
what about this Net.WebRequestMethods.Ftp.MakeDirectory?

of course you'd have to set an instance to net,ftpwebrequest and set the method to makedirectory(first one up top).

soo e.g.


Expand|Select|Wrap|Line Numbers
  1.  
  2.  Dim myftprequest As Net.FtpWebRequest = CType(Net.FtpWebRequest.Create(host), System.Net.FtpWebRequest)
  3.         myftprequest.Credentials = New System.Net.NetworkCredential(username, password)
  4.         myftprequest.Method = System.Net.WebRequestMethods.Ftp.MakeDirectory
  5. 'code to upload it
  6.  
Aug 23 '08 #2
Hi
I have to make directory and subdirectory one into another.
say creating a Avi directory then in that i have to create another directory kavi in that subdiretcory another and so on.,.....

plz help me out reg this.
Aug 24 '08 #3
Thanks for the reply.....
it works ......
but now i have to create multiple subdirectories one into another...
say
kavi(subdirectory)--->avi(subdirectory)---->and so on......
Aug 24 '08 #4
Curtis Rutland
3,256 Expert 2GB
I'm sorry, but figure it out for yourself. If you have the code to make a directory, the code for a subdirectory is no different, you just have to change the target.

You're not going to get everything spoon fed to you here.
Aug 24 '08 #5
joedeene
583 512MB
exactly as insertalias said, we cant give you everything, im here to help although i did give you a code sample to get you started, i can continue to giving you answers because i dont know if your just copying and pasting or learning, and plus you have to show us *some* code of yours to get further help, so i will ask how do you want to make the subdirectories ? and what have you done so far, with helping yourself to make this ?

joedeene
Aug 24 '08 #6
okk.....here is the code for FTP ....It is working fine ....but when I am trying to create subdirectories ,it gives an error..

------------------------------------------------------------------------------------------------------------------
Shared Sub main2(ByVal zipdir, ByVal systemname)

'FTP creadentials'
Dim servertemp As String = "ftp://hydhtc25116/"
Dim username As String = "hydhtc25116\root"
Dim password As String = "infy@123"
Dim host As String = servertemp

'Renaming the zip file as the current system date'
Dim filename As String
filename = zipdir
Dim New1 As String
Dim month1 As String
Dim year1 As String
Dim day1 As String
day1 = DatePart("d", DateTime.Now)
month1 = DatePart("m", DateTime.Now)
year1 = DatePart("yyyy", DateTime.Now)
New1 = systemname + "_" + day1 + "-" + month1 + "-" + year1

'Declaring the FTP zip filename as the current system Date'
Dim remoteFile As String = "/" & New1 & ".zip"


'1. Create a request: must be in ftp://hostname format'
Dim URI As String = host & remoteFile
Dim ftp As Net.FtpWebRequest = CType(Net.FtpWebRequest.Create(URI), Net.FtpWebRequest)

'2. Set credentials

ftp.Credentials = New System.Net.NetworkCredential(username, password)

'3. Settings and action

ftp.KeepAlive = False

'4. we want a binary transfer, not textual data

ftp.UseBinary = True

'5. Define the action required (in this case, download a file)

ftp.Method = System.Net.WebRequestMethods.Ftp.UploadFile

'6. Reading the content of the zip file'

Dim bFile() As Byte = System.IO.File.ReadAllBytes(filename & "/" & New1 & ".zip")
Dim clsStream As System.IO.Stream = ftp.GetRequestStream()

'Writing the content of the file'
clsStream.Write(bFile, 0, bFile.Length)
clsStream.Close()
clsStream.Dispose()
clsStream.Flush()



End Sub
-----------------------------------------------------------------------------------------------------------------
here is the code for logic of directory which i want to create on server...


---------------------------------------------------------------------------------------------------------

Sub Main()
Dim str As String = "C:\ProgramFiles\Ext\ABC\Stv\text.txt"
Dim newstr As String = str.Substring(0, 1)
Console.WriteLine(newstr)
Dim new1 As String = str.Substring(3, str.LastIndexOf("\") - 2)
Console.WriteLine(new1)
If Not Directory.Exists("C:\C\" & new1) Then
Directory.CreateDirectory("C:\C\" & new1)
End If


End Sub

--------------------------------------------------------------------------------------------------------------
Aug 25 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Michał Kurowski | last post by:
Hi, I'd like to ask you whether anyone have built python-ldap against Sun ONE Directory v5.2 on a Solaris 9. Seems developers do not support such config, but many places on the web suggest it...
1
by: raghavendra | last post by:
How to create a server-side cookie using C#
0
by: A.M | last post by:
Hi, Our active directory server also is our intranet server. I can not find ASPNET user (mentioned in kb article 317955) in list of AD users. Does anyone knows user name is being used by process...
7
by: thisis | last post by:
Hi All, i have this.asp page: <script type="text/vbscript"> Function Body_Onload() ' create the object Set obj = Server.CreateObject("UploadImage.cTest") ' use method of the object...
18
by: troywalker | last post by:
I am new to LDAP and Directory Services, and I have a project that requires me to authenticate users against a Sun Java System Directory Server in order to access the application. I have found...
5
by: AmitGujrathi | last post by:
Hi all,,, can anybody pls tell me how to create directory on web server using C#.Net windows application thanks in Advance Amit
4
by: kathy30 | last post by:
I'm storing files in SQL and retrieving them when needed to the user's C: Drive This is accessed on our Intranet site, the problem is the create directory and saving files happens on the Server...
3
by: yawnmoth | last post by:
I'm trying to connect to an Active Directory server and am having some difficulties. Here's the code I'm using: <?php if (!($ldap = ldap_connect('domain.tld')) { exit('unable to connect'); }...
1
luckysanj
by: luckysanj | last post by:
Dear All, I want to make a radius server for user authentication for my PPPoE client so can any one have good idea or links to create Radius server easily. I see the many links on google but i...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.