List Info

Thread: download file to client




download file to client
country flaguser name
United States
2007-10-14 19:31:29
is there a way to download a file from the web server to the
clients
machines?  I have a word doc on the web server that needs to
be
download to the users C:


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "ASP.Net Community" group.
To post to this group, send email to aspnetgooglegroups.com
To unsubscribe from this group, send email to
aspnet-unsubscribegooglegroups.com
For more options, visit this group at http://gr
oups.google.com/group/aspnet?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: download file to client
country flaguser name
United States
2007-10-15 09:54:30
Add the Word document to your project, add a hyperlink
control and set
it's NavigateUrl property to your newly added file.  It's up
to the
client with the browser where it gets saved on the client's
machine.

On Oct 14, 7:31 pm, mike11d11 <mike11...yahoo.com> wrote:
> is there a way to download a file from the web server
to the clients
> machines?  I have a word doc on the web server that
needs to be
> download to the users C:


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "ASP.Net Community" group.
To post to this group, send email to aspnetgooglegroups.com
To unsubscribe from this group, send email to
aspnet-unsubscribegooglegroups.com
For more options, visit this group at http://gr
oups.google.com/group/aspnet?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: download file to client
user name
2007-10-14 23:35:13
Yes, Definitely Mike,
&nbsp;
Please gothrough the Coding :
 ;
 
Imports System.Threading

Dim req As WebRequest = WebRequest.Create(http://xyz.com/file.doc)

&nbsp; &nbsp; &nbsp;   Dim resp As WebResponse = req.GetResponse()
&nbsp; &nbsp; &nbsp;   Dim webstream As Stream = resp.GetResponseStream()
 &nbsp;   ; &nbsp; Dim mem As MemoryStream = New MemoryStream()

&nbsp; &nbsp; &nbsp;   ' Read the NetworkStream into the MemoryStream.
 &nbsp;   ; &nbsp; Dim data(100000) As Byte
 ; &nbsp; &nbsp; &nbsp; Dim dataLen As Integer
&nbsp; &nbsp;   ;  Do
 &nbsp;   ; &nbsp; &nbsp; &nbsp; dataLen = webstream.Read(data, 0, 100000)
&nbsp; &nbsp;   ; &nbsp; &nbsp;  If dataLen = 0 Then Exit Do
 ; &nbsp; &nbsp; &nbsp; &nbsp;   mem.Write(data, 0, dataLen)
&nbsp;   ; &nbsp;  Loop
 ; &nbsp; &nbsp; &nbsp; Dim x() As Byte = data
 ; &nbsp; &nbsp; &nbsp; 'If File.Exists(Server.MapPath(";UploadFiles/TestNew1.csv")) = True Then
 ; &nbsp; &nbsp; &nbsp; ' ; &nbsp; File.Delete (Server.MapPath(&quot;UploadFiles/TestNew1.csv"))
 &nbsp; &nbsp;   ; 'End If
 &nbsp;   ; &nbsp; Dim f As FileStream = New FileStream("c://UploadFiles/TestNew1.csv", FileMode.OpenOrCreate, FileAccess.Write)
&nbsp; &nbsp; &nbsp;   f.Write (x, 0, data.Length)
 &nbsp; &nbsp;   ; 'Response.Write(Server.MapPath("UploadFiles/TestNew1.csv"))
&nbsp; &nbsp;   ;  f.Close()
  ; &nbsp; &nbsp;  '//Code to Read CSV File line by line and Insert into Database
&nbsp;   ; &nbsp;  'Dim sr As New IO.StreamReader(&quot;c:TestNew4.csv";)
 &nbsp; &nbsp;   ; Dim strpath As String = "c://UploadFiles/TestNew1.csv"
&nbsp; &nbsp;   ;  Dim sr As New IO.StreamReader(strpath)
 &nbsp;   ; &nbsp; Dim line As String = "&quot;
 &nbsp; &nbsp;   ; Do While sr.Peek
  ; &nbsp; &nbsp; &nbsp; &nbsp;  line = sr.ReadLine
 &nbsp; &nbsp; &nbsp;   ; &nbsp; If Not (line.StartsWith(&quot;Time";) Or line.EndsWith("Comments&quot;)) Then
 ; &nbsp; &nbsp; &nbsp; &nbsp;   ; &nbsp;  Dim columns() As String = line.Split(",&quot;c) 'gives us an array of each item in the line seperated by the commas
&nbsp;   ; &nbsp; &nbsp; &nbsp; &nbsp;   ; InsertRow(columns(0), columns(1).ToString, columns(2), columns(3), columns(4), columns(5), columns(6), columns(7))
 &nbsp; &nbsp; &nbsp;   ; &nbsp; End If
 &nbsp;   ; &nbsp; Loop



&nbsp;
On 10/15/07, mike11d11 < mike11d11yahoo.com">mike11d11yahoo.com> wrote:

is there a way to download a file from the web server to the clients
machines?&nbsp; I have a word doc on the web server that needs to be
download to the users C:

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "ASP.Net Community&quot; group.
To post to this group, send email to aspnetgooglegroups.com
To unsubscribe from this group, send email to aspnet-unsubscribegooglegroups.com
For more options, visit this group at http://groups.google.com/group/aspnet?hl=en
-~----------~----~----~----~------~----~------~--~---

Re: download file to client
country flaguser name
United States
2007-10-17 06:07:31

mike11d11 wrote:
> is there a way to download a file from the web server
to the clients
> machines?  I have a word doc on the web server that
needs to be
> download to the users C:

Go for FTP my code looks like this :




 public static void Rename(string currentFilename, string
newFilename)
      {
          FtpWebRequest reqFTP;
          try
          {
              OrderFTPMixedBO ordersBOList =
OrderDAL.getFileInformation(3);

              reqFTP =
(FtpWebRequest)FtpWebRequest.Create(new
Uri(currentFilename));
              reqFTP.Method = WebRequestMethods.Ftp.Rename;
              reqFTP.RenameTo = newFilename;
              reqFTP.UseBinary = true;
              reqFTP.Credentials = new
NetworkCredential(ordersBOList.ftpDetails.Username,
ordersBOList.ftpDetails.Password );
              FtpWebResponse response =
(FtpWebResponse)reqFTP.GetResponse();
              Stream ftpStream =
response.GetResponseStream();
              ftpStream.Close();
              response.Close();
          }
          catch (UriFormatException ex)
          {
              throw ex;
          }
          catch (WebException ex)
          {
              throw ex;
          }

      }

      public static string[] GetFileList(string ftpName,
string
ftpPwd,string ftpaddress)
      {
          string[] downloadFiles;
          StringBuilder result = new StringBuilder();
          FtpWebRequest reqFTP;
          try
          {
              reqFTP =
(FtpWebRequest)FtpWebRequest.Create(new
Uri(ftpaddress));
              reqFTP.UseBinary = true;
              reqFTP.Credentials = new
NetworkCredential(ftpName,
ftpPwd);
              reqFTP.Method =
WebRequestMethods.Ftp.ListDirectory;
              WebResponse response = reqFTP.GetResponse();
              StreamReader reader = new
StreamReader(response.GetResponseStream());
              string line = reader.ReadLine();
              while (line != null)
              {
                  result.Append(line);
                  result.Append("n");
                  line = reader.ReadLine();
              }
             
result.Remove(result.ToString().LastIndexOf('n'), 1);
              reader.Close();
              response.Close();

              return result.ToString().Split('n');
          }
          catch (Exception ex)
          {
             // throw ex;
              downloadFiles = null;
              return downloadFiles;
          }
      }
      public static void Download(string downloadUrl, string
ftpName,
string ftpPwd)
      {

          Stream responseStream = null;
          FileStream fileStream = null;
          StreamReader reader = null;
          try
          {
              FtpWebRequest downloadRequest
=(FtpWebRequest)WebRequest.Create(downloadUrl);

              NetworkCredential cre = new
NetworkCredential(ftpName,
ftpPwd);//get Credentials
              downloadRequest.Credentials = cre;
              FtpWebResponse downloadResponse
=(FtpWebResponse)downloadRequest.GetResponse();
              responseStream =
downloadResponse.GetResponseStream();
              string fileName
=Path.GetFileName(downloadRequest.RequestUri.AbsolutePath);
              if (fileName.Length == 0)
              {
                  reader = new
StreamReader(responseStream);
                  reader.ReadToEnd();

              }
              else
              {
                  string  
newfileName="polknewleads.txt";
                 
//File.Move(AppDomain.CurrentDomain.BaseDirectory +
"/Orders/" + newfileName,
AppDomain.CurrentDomain.BaseDirectory + "/
CompleatedOrders/" + newfileName);
                
File.Delete(AppDomain.CurrentDomain.BaseDirectory + "/
Orders/" + newfileName);

                  fileStream =
File.Create(AppDomain.CurrentDomain.BaseDirectory +
"/Orders/" +
newfileName);

                  byte[] buffer = new byte[1024];
                  int bytesRead;
                  while (true)
                  {
                      bytesRead =
responseStream.Read(buffer, 0,
buffer.Length);
                      if (bytesRead == 0)
                          break;
                      fileStream.Write(buffer, 0,
bytesRead);
                  }
                  //File.Move(fileName, newfileName);

              }

          }
          //catch (UriFormatException ex)
          //{
          //    throw ex;
          //}
          //catch (WebException ex)
          //{
          //    throw ex;
          //}
          //catch (IOException ex)
          //{
          //    throw ex;
          //}
          finally
          {
              if (reader != null)
                  reader.Close();
              else if (responseStream != null)
                  responseStream.Close();
              if (fileStream != null)
                  fileStream.Close();
          }
      }


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "ASP.Net Community" group.
To post to this group, send email to aspnetgooglegroups.com
To unsubscribe from this group, send email to
aspnet-unsubscribegooglegroups.com
For more options, visit this group at http://gr
oups.google.com/group/aspnet?hl=en
-~----------~----~----~----~------~----~------~--~---


Re: download file to client
country flaguser name
United States
2007-10-21 21:28:42
http:
//www.codeproject.com/vb/net/FtpClient.asp
 you can access this url to find the answer


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "ASP.Net Community" group.
To post to this group, send email to aspnetgooglegroups.com
To unsubscribe from this group, send email to
aspnet-unsubscribegooglegroups.com
For more options, visit this group at http://gr
oups.google.com/group/aspnet?hl=en
-~----------~----~----~----~------~----~------~--~---


[1-5]

about | contact  Other archives ( Real Estate discussion Medical topics )