На главную Наши проекты:
Журнал   ·   Discuz!ML   ·   Wiki   ·   DRKB   ·   Помощь проекту
ПРАВИЛА FAQ Помощь Участники Календарь Избранное RSS
msm.ru
  
> Не получается скачать файл с сервера. , Не получается скачать файл с сервера.
    Здравствуйте! Столкнулся с проблемой загрузки файла с сервера. Есть некая ссылка http://www.google.com/finance/historical?c...4&startdate=Nov 11, 2008&enddate=Nov 10, 2009&num=30&ei=_fkXVbHsKsGPwAOM8YHoBQ&output=csv
    по клику на которой скачивается msft.csv файл.
    ExpandedWrap disabled
      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".
      ExpandedWrap disabled
        using System.Net;


      ExpandedWrap disabled
        using (WebClient Client = new WebClient())
                    {
                        Client.DownloadFile("http://www.google.com/finance/historical?q=NASDAQ%3AMSFT&ei=6KgXVbG5O-qgwAPTqoCICA&output=csv", "msft.csv");
                    }


      ;)
        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.
          Dmitriy78781, а файл то есть?

          Цитата Dmitriy78781 @
          Could not find file 'c:\windows\system32\inetsrv\msft.csv'.
            Программа так работает. А на сервере не хочет.

            Добавлено
            На локальном сервере файл скачиваеться и находится рядом с файлом запускающим 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 выполняется в родительской папки перед папкой содержащей все классы.
              Цитата Dmitriy78781 @
              А на сервере не хочет.

              :D ну видать на сервере есть какие то ограничения на запись на диск куда хочешь нельзя записывать... попробуй путь указать куда нить в конкретную дерикторию, а не что бы рядом ложило файл с исполняемыми
              0 пользователей читают эту тему (0 гостей и 0 скрытых пользователей)
              0 пользователей:


              Рейтинг@Mail.ru
              [ Script execution time: 0,0286 ]   [ 17 queries used ]   [ Generated: 28.03.24, 23:10 GMT ]