Наши проекты:
Журнал · Discuz!ML · Wiki · DRKB · Помощь проекту |
||
ПРАВИЛА | FAQ | Помощь | Поиск | Участники | Календарь | Избранное | RSS |
[18.116.24.105] |
|
Сообщ.
#1
,
|
|
|
Здравствуйте! Столкнулся с проблемой загрузки файла с сервера. Есть некая ссылка http://www.google.com/finance/historical?c...4&startdate=Nov 11, 2008&enddate=Nov 10, 2009&num=30&ei=_fkXVbHsKsGPwAOM8YHoBQ&output=csv
по клику на которой скачивается msft.csv файл. using System; using System.Data; using System.Configuration; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using System.Text; using System.Collections; using System.Collections.Generic; using System.IO; using System.Net; using System.Xml; namespace System { public class Download { static string txt = "http://www.google.com/finance/historical?q=NASDAQ%3AMSFT&ei=6KgXVbG5O-qgwAPTqoCICA&output=csv"; static string fileName = "msft.csv"; public static void WriteResponseTxt() { if (String.IsNullOrEmpty(txt)) return; if (HttpContext.Current == null) return; var response = HttpContext.Current.Response; response.Clear(); response.Charset = "utf-8"; response.ContentType = "text/plain"; response.AddHeader("content-disposition", string.Format("attachment; filename={0}", fileName)); response.BinaryWrite(Encoding.UTF8.GetBytes(txt)); response.Flush(); } } } Ошибка выполнения JavaScript: Sys.WebForms.PageRequestManagerParserErrorException: Не удалось обработать сообщение, полученное от сервера. К общим причинам ошибки относится то, что при изменении ответа посредством вызовов Response.Write(), фильтры ответов, HttpModules или трассировка сервера отключены. Подробности: Ошибка при разборе около "http://www.google.co". |
Сообщ.
#2
,
|
|
|
using System.Net; using (WebClient Client = new WebClient()) { Client.DownloadFile("http://www.google.com/finance/historical?q=NASDAQ%3AMSFT&ei=6KgXVbG5O-qgwAPTqoCICA&output=csv", "msft.csv"); } |
Сообщ.
#3
,
|
|
|
Server Error in '/Dmitriy878787' Application.
Could not find file 'c:\windows\system32\inetsrv\msft.csv'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.IO.FileNotFoundException: Could not find file 'c:\windows\system32\inetsrv\msft.csv'. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [FileNotFoundException: Could not find file 'c:\windows\system32\inetsrv\msft.csv'.] System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) +9726255 System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath) +1142 System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options) +82 System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize) +87 System.IO.StreamReader..ctor(String path, Encoding encoding) +16 System.IO.File.InternalReadAllLines(String path, Encoding encoding) +80 System.IO.File.ReadAllLines(String path) +37 EpamSystem.Csv.ReadCSVFile(String pathToCsvFile) in G:\Собеседование\Брест\EpamSystems\EpamSystem\EpamSystem\EpamSystem\Csv.cs:30 EpamSystem.AllTechnology.SetQuotes(String StrEnterHistData, DateTime DateBegin, DateTime DateEnd) in G:\Собеседование\Брест\EpamSystems\EpamSystem\EpamSystem\EpamSystem\AllTechnology.cs:46 EpamSystem._Default.GetQuotes_Click(Object sender, EventArgs e) in G:\Собеседование\Брест\EpamSystems\EpamSystem\EpamSystem\EpamSystem\Default.aspx.cs:115 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563 Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1025 Добавлено На сервере пишет. Добавлено NOTICE:This website (http://aspspider.info/Dmitriy878787/default.aspx) is hosted using AspSpider.com free educational hosting service. Do not provide any sensitive information through this website unless you trust the owner. Report Abuse Visit AspSpider.com. |
Сообщ.
#4
,
|
|
|
Dmitriy78781, а файл то есть?
Цитата Dmitriy78781 @ Could not find file 'c:\windows\system32\inetsrv\msft.csv'. |
Сообщ.
#5
,
|
|
|
Программа так работает. А на сервере не хочет.
Добавлено На локальном сервере файл скачиваеться и находится рядом с файлом запускающим visual studio а на сервере я не знаю что там происходит. На сервер я сбросил папку со всеми классами, default папки App_Data,bin,obj, Properties,Service References есть и msft.csv. Сайт работает, а msft.csv не видет Добавлено На сервер я сбросил содержимое папки со всеми классами, default папки App_Data,bin,obj, Properties,Service References и msft.csv Добавлено На локальном сервере файл msft.csv выполняется в родительской папки перед папкой содержащей все классы. |
Сообщ.
#6
,
|
|
|
Цитата Dmitriy78781 @ А на сервере не хочет. ну видать на сервере есть какие то ограничения на запись на диск куда хочешь нельзя записывать... попробуй путь указать куда нить в конкретную дерикторию, а не что бы рядом ложило файл с исполняемыми |