|
List Info
Thread: download file to client
|
|
| download file to client |
  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 aspnet googlegroups.com
To unsubscribe from this group, send email to
aspnet-unsubscribe googlegroups.com
For more options, visit this group at http://gr
oups.google.com/group/aspnet?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: download file to client |
  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 aspnet googlegroups.com
To unsubscribe from this group, send email to
aspnet-unsubscribe googlegroups.com
For more options, visit this group at http://gr
oups.google.com/group/aspnet?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: download file to client |

|
2007-10-14 23:35:13 |
|
Yes, Definitely Mike,
Please gothrough the Coding :
Imports System.Threading
Dim req As WebRequest = WebRequest.Create(http://xyz.com/file.doc)
Dim resp As WebResponse = req.GetResponse() Dim webstream As Stream = resp.GetResponseStream() Dim mem As MemoryStream = New MemoryStream()
' Read the NetworkStream into the MemoryStream. Dim data(100000) As Byte Dim dataLen As Integer Do dataLen = webstream.Read(data, 0, 100000) If dataLen = 0 Then Exit Do
mem.Write(data, 0, dataLen) Loop Dim x() As Byte = data 'If File.Exists(Server.MapPath("UploadFiles/TestNew1.csv")) = True Then ' File.Delete
(Server.MapPath("UploadFiles/TestNew1.csv")) 'End If Dim f As FileStream = New FileStream("c://UploadFiles/TestNew1.csv", FileMode.OpenOrCreate, FileAccess.Write) f.Write
(x, 0, data.Length) 'Response.Write(Server.MapPath("UploadFiles/TestNew1.csv")) f.Close() '//Code to Read CSV File line by line and Insert into Database 'Dim sr As New
IO.StreamReader("c:TestNew4.csv") Dim strpath As String = "c://UploadFiles/TestNew1.csv" Dim sr As New IO.StreamReader(strpath) Dim line As String = "" Do While
sr.Peek line = sr.ReadLine If Not (line.StartsWith("Time") Or line.EndsWith("Comments")) Then Dim columns() As String = line.Split(","c) 'gives us an array of each item in the line seperated by the commas
InsertRow(columns(0), columns(1).ToString, columns(2), columns(3), columns(4), columns(5), columns(6), columns(7)) End If Loop
On 10/15/07, mike11d11 < mike11d11 yahoo.com">mike11d11 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 aspnet googlegroups.com To unsubscribe from this group, send email to aspnet-unsubscribe googlegroups.com For more options, visit this group at http://groups.google.com/group/aspnet?hl=en -~----------~----~----~----~------~----~------~--~---
|
| Re: download file to client |
  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 aspnet googlegroups.com
To unsubscribe from this group, send email to
aspnet-unsubscribe googlegroups.com
For more options, visit this group at http://gr
oups.google.com/group/aspnet?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
| Re: download file to client |
  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 aspnet googlegroups.com
To unsubscribe from this group, send email to
aspnet-unsubscribe googlegroups.com
For more options, visit this group at http://gr
oups.google.com/group/aspnet?hl=en
-~----------~----~----~----~------~----~------~--~---
|
|
[1-5]
|
|