2014-11-18 1 views
-3

나는 C# 프로그램을 가지고 있으며, 나는 그것으로 MS 액세스 데이터베이스를 사용하고있다. 그래서 어떻게 내 도메인에 코드로 데이터베이스를 업로드 할 수 있는가? MYSQL 도메인 "Linux"를 사용하고 있습니다.Ms 액세스 데이터베이스를 ftp에 업로드하는 방법은 무엇입니까?

+1

"코드에 의해"그게 무슨 뜻 이죠? –

+0

FTP 프로그램 창을 사용하거나 다른 방법으로 시작하거나 자신의 코드를 작성하면 코딩 팜이 아닙니다 .. 그래서 독자가 직접 시도한 것을 보여 주어야합니다. – MethodMan

+0

나는 묻습니다. 그것이 가능하다면 !!? –

답변

0

이 어떤 파일을 작동합니다

private void UploadFiles() 
{ 
    string filename = Server.MapPath("file1.txt"); 
    string ftpServerIP = "ftp.demo.com/"; 
    string ftpUserName = "dummy"; 
    string ftpPassword = "dummy"; 

    FileInfo objFile = new FileInfo(filename); 
    FtpWebRequest objFTPRequest; 

    // Create FtpWebRequest object 
    objFTPRequest = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + ftpServerIP + "/" + objFile.Name)); 

    // Set Credintials 
    objFTPRequest.Credentials = new NetworkCredential(ftpUserName, ftpPassword); 

    // By default KeepAlive is true, where the control connection is 
    // not closed after a command is executed. 
    objFTPRequest.KeepAlive = false; 

    // Set the data transfer type. 
    objFTPRequest.UseBinary = true; 

    // Set content length 
    objFTPRequest.ContentLength = objFile.Length; 

    // Set request method 
    objFTPRequest.Method = WebRequestMethods.Ftp.UploadFile; 

    // Set buffer size 
    int intBufferLength = 16 * 1024; 
    byte[] objBuffer = new byte[intBufferLength]; 

    // Opens a file to read 
    FileStream objFileStream = objFile.OpenRead(); 

    try 
    { 
     // Get Stream of the file 
     Stream objStream = objFTPRequest.GetRequestStream(); 

     int len = 0; 

     while ((len = objFileStream.Read(objBuffer, 0, intBufferLength)) != 0) 
     { 
      // Write file Content 
      objStream.Write(objBuffer, 0, len); 

     } 

     objStream.Close(); 
     objFileStream.Close(); 
    } 
    catch (Exception ex) 
    { 
     throw ex; 
    } 
} 
관련 문제