Click here to Skip to main content
15,884,425 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: button disable until all required fields are filled Pin
Member 870181321-Feb-13 2:07
Member 870181321-Feb-13 2:07 
GeneralRe: button disable until all required fields are filled Pin
Member 870181321-Feb-13 5:00
Member 870181321-Feb-13 5:00 
GeneralRe: button disable until all required fields are filled Pin
Member 870181320-Feb-13 22:09
Member 870181320-Feb-13 22:09 
QuestionPlease Wait .... Pin
jojoba201119-Feb-13 21:19
jojoba201119-Feb-13 21:19 
AnswerRe: Please Wait .... Pin
Sandeep Mewara19-Feb-13 22:11
mveSandeep Mewara19-Feb-13 22:11 
AnswerRe: Please Wait .... Pin
Karthik Harve20-Feb-13 19:07
professionalKarthik Harve20-Feb-13 19:07 
QuestionRe: Please Wait .... Pin
jojoba201122-Feb-13 23:26
jojoba201122-Feb-13 23:26 
Questionftp uploaded files are empty Pin
Omid Reza Aryafar19-Feb-13 2:43
Omid Reza Aryafar19-Feb-13 2:43 
Hi every one,

strange issue, im trying to upload a whole simple one-page asp.net website to a remote ftp by my method called uploadFolderContents().

every structure and files gets uploade, but the contents of files are gone. all of them are empty even txt files.

i tried to upload a single txt file, the file appears on remote but empty as well.
oh, it also changes the source files, makes them all empty too!!!!

some hlp pls


clsFile.ftp ftp = new clsFile.ftp("ftp", "un", "pwd");
ftp.uploadFolderContents("httpdocs/omid", "E:\\omid");



C#
public bool uploadFolderContents(string remoteFolder, string localFolder)
        {
            bool rslt = false;

            try
            {
                string[] files = Directory.GetFiles(localFolder);
                string[] dirs = Directory.GetDirectories(localFolder);
                foreach (string file in files)
                {
                    uploadFile(remoteFolder + "/" + Path.GetFileName(file), file);
                }
                foreach (string dir in dirs)
                {
                    createFolder(remoteFolder + "/" + Path.GetFileName(dir));
                    uploadFolderContents(remoteFolder + "/" + Path.GetFileName(dir), dir);
                }

                rslt = true;
            }
            catch (Exception)
            {
                rslt = false;
            }

            return rslt;
        }



C#
public void uploadFile(string remoteFile, string localFile)
{
    try
    {
        /* Create an FTP Request */
        ftpRequest = (FtpWebRequest)FtpWebRequest.Create(host + "/" + remoteFile);
        /* Log in to the FTP Server with the User Name and Password Provided */
        ftpRequest.Credentials = new NetworkCredential(user, pass);
        /* When in doubt, use these options */
        ftpRequest.UseBinary = true;
        ftpRequest.UsePassive = true;
        ftpRequest.KeepAlive = true;
        /* Specify the Type of FTP Request */
        ftpRequest.Method = WebRequestMethods.Ftp.UploadFile;
        /* Establish Return Communication with the FTP Server */
        ftpStream = ftpRequest.GetRequestStream();
        /* Open a File Stream to Read the File for Upload */
        FileStream localFileStream = new FileStream(localFile, FileMode.Create);
        /* Buffer for the Downloaded Data */
        byte[] byteBuffer = new byte[bufferSize];
        int bytesSent = localFileStream.Read(byteBuffer, 0, bufferSize);
        /* Upload the File by Sending the Buffered Data Until the Transfer is Complete */
        try
        {
            while (bytesSent != 0)
            {
                ftpStream.Write(byteBuffer, 0, bytesSent);
                bytesSent = localFileStream.Read(byteBuffer, 0, bufferSize);
            }
        }
        catch (Exception ex) { Console.WriteLine(ex.ToString()); }
        /* Resource Cleanup */
        localFileStream.Close();
        ftpStream.Close();
        ftpRequest = null;
    }
    catch (Exception ex) { Console.WriteLine(ex.ToString()); }
    return;
}


modified 19-Feb-13 8:55am.

AnswerRe: ftp uploaded files are empty Pin
Richard Deeming19-Feb-13 4:17
mveRichard Deeming19-Feb-13 4:17 
GeneralRe: ftp uploaded files are empty Pin
Omid Reza Aryafar19-Feb-13 4:34
Omid Reza Aryafar19-Feb-13 4:34 
QuestionCan a Compare validator fire when either of two controls changes? Pin
darookie9918-Feb-13 17:13
darookie9918-Feb-13 17:13 
AnswerRe: Can a Compare validator fire when either of two controls changes? Pin
Brij18-Feb-13 19:09
mentorBrij18-Feb-13 19:09 
GeneralRe: Can a Compare validator fire when either of two controls changes? Pin
darookie9919-Feb-13 13:51
darookie9919-Feb-13 13:51 
AnswerRe: Can a Compare validator fire when either of two controls changes? Pin
ZurdoDev19-Feb-13 2:32
professionalZurdoDev19-Feb-13 2:32 
AnswerRe: Can a Compare validator fire when either of two controls changes? Pin
Keith Barrow19-Feb-13 4:07
professionalKeith Barrow19-Feb-13 4:07 
Questionmultilanguage application Pin
Member 870181318-Feb-13 7:39
Member 870181318-Feb-13 7:39 
AnswerRe: multilanguage application Pin
Sandeep Mewara18-Feb-13 7:58
mveSandeep Mewara18-Feb-13 7:58 
GeneralRe: multilanguage application Pin
Member 870181325-Feb-13 21:59
Member 870181325-Feb-13 21:59 
GeneralRe: multilanguage application Pin
Sandeep Mewara25-Feb-13 23:24
mveSandeep Mewara25-Feb-13 23:24 
GeneralRe: multilanguage application Pin
Member 870181326-Feb-13 1:44
Member 870181326-Feb-13 1:44 
GeneralRe: multilanguage application Pin
Sandeep Mewara26-Feb-13 2:04
mveSandeep Mewara26-Feb-13 2:04 
GeneralRe: multilanguage application Pin
Member 870181326-Feb-13 2:51
Member 870181326-Feb-13 2:51 
GeneralRe: multilanguage application Pin
Member 870181326-Feb-13 5:20
Member 870181326-Feb-13 5:20 
AnswerRe: multilanguage application Pin
Sandeep Mewara26-Feb-13 5:38
mveSandeep Mewara26-Feb-13 5:38 
GeneralRe: multilanguage application Pin
Member 870181327-Feb-13 4:38
Member 870181327-Feb-13 4:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.