.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

FileStream wont close ?

Posted By:      Posted Date: October 14, 2010    Points: 0   Category :ASP.Net

Hey here is my code:

public static bool Download(string filePath, string fileName)
            FtpWebRequest reqFTP;
                FileStream outputStream = new FileStream(filePath + "\\" + fileName, FileMode.Create);

                reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://" + ftpServerIP + "//" + fileName));
                reqFTP.Method = WebRequestMethods.Ftp.DownloadFile;
                reqFTP.UseBinary = true;
                reqFTP.UsePassive = true;
                reqFTP.KeepAlive = true;
                reqFTP.Timeout = 300000;
                reqFTP.ReadWriteTimeout = 1200000;
                reqFTP.Credentials = new NetworkCredential(ftpUserID, ftpPassword);
                FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();
                Stream ftpStream = response.GetResponseStream();
                long cl = response.ContentLength;
                int bufferSize = 2048;
                int readCount;
                byte[] buffer = new byte[bufferSize];

                readCount = ftpStream.Read(buffer, 0, bufferSize);
                while (readCount > 0)
                    outputStream.Write(buffer, 0, readCount);
                    readCount = ftpStream.Read(buffer, 0, bufferSize);

View Complete Post

More Related Resource Links

WebDev.WebServer.exe has encounted a problem and needs to close when trying to view page in browser


Hi, whenever I load an aspx page in vwde2008, I get the message in the subject of this post.  After I click Ok on that, I get a dialog box, Unable to Connect to the ASP.Net development center.  What can I do to troubleshoot?

I am using Windows XP SP3, vwde2008 with SP1, on a HP desktop.  Also using Office 2003 if that is relevant at all.

Thanks, Justin

How to set session timeout and clear session in asp.net C# ? And kill session when close the web app


hi ,

How to set session timeout and clear session in web.config and login.aspx  ? And when we close the web application , the session must be cleared ?

I have use session.abandon as per below but is not working . Pls advise .


        protected void btnLogout_Click(object sender, EventArgs e)



file upload in Create User Wizard Created User event with UpdatePanel Tag wont work?



In my Create User Wizard1 Created User Wizard Event, I am collecting extra information from text boxes and allowing

the user to uplad a file.



I have put the Submit button within an Update Panel Tag but since I have done this it does not work.

Is there a way round it. In this situation would you use a trigger.?


<br />

  <asp:UpdatePanel ID="UpdatePanel2" runat="server">

  <asp:Button ID="StepNextButton" runat="server"  CommandName="MoveNext"  align="middle"
                                            Text="Submit my Profile" />

How to Use Window.close() in C#


Hello Alll

Please Tell me  How to Use Window.close() in C#.. In this case i have to handle both serverside event and client side..


Textbox text populated by Session Variable wont update into SQL with new text


Hi everyone, I have what I think is a weird issue. I send text from one page to another via Session Variable. When page 2 loads, the text box has the session text set, but if the user changes the text and clicks the button, the SQL database is update with the original session text. If I remove the redirect from the page 2 button_Click method, then, the page refreshes with the textbox reverting to the session text and thr SQLDataSource has the session text added to it.

Why would the button click cause the textbox refresh with the text from the pageLoad before updating the data source?


Partial Class _1
    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Session("UpdateProd") = "Have some text here to send to a textbox on page 2"
    End Sub
End Class

Partial Class _2
    Inherits System.Web.UI.Page


Partial Views and Popups...After clicking on Close need to refresh the page....


Hi All,


I amusing the PopUp example as suggestedin the above forum link.....

But now i want to Refresh the page after clicking on Close(x) ...

So please help me....

Please advice...

Thanks in advance...



thickbox close



how to call below jquery (thickbox)  in codebehind

$("#TB_window").append("<a href='' id='TB_ImageOff' title='Close'><img id='TB_Image' src='"+url+"' width='"+imageWidth+"' height='"+imageHeight+"' alt='"+caption+"'/></a>" + "<div id='TB_caption'>"+caption+"<div id='TB_secondLine'>" + TB_imageCount + TB_PrevHTML + TB_NextHTML + "</div></div><div id='TB_closeWindow'><a href='#' id='TB_closeWindowButton' title='Close'>close</a> or Esc Key</div>");         

Refresh parent window and close popup window.


Hi All,

I've been spent the last couple hours trying to work on this issue. I an creating Facebook Oauth stuff, when i click on parent window. The popup shows the Facebook login, when i logged in with my details, it redirects to my site. But i need to close this popup after returning and refrsh the parent window.

can you please provide me this kind of stuff. i already spent whole day in this... Sealed Cry

If i could solve this then i will go for another logic but stucked on 1st step.



Close Tab doesn't logout


When closing my tab, Formsauthentication doesn't clear, thanks!

protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)

      if (Classes.CStaticDataAccess.AuthenticateUser(Login1.UserName, Login1.Password))
        FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, Login1.UserName, DateTime.Now, DateTime.Now.AddMinutes(1), false, "");
        string secureTicket = FormsAuthentication.Encrypt(ticket);
        HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, secureTicket);
        string redirectUrl = FormsAuthentication.GetRedirectUrl(Login1.UserName, false);

       // System.Web.Security.FormsAuthentication.SetAuthCookie(Login1.UserName, false);
        e.Authenticated = true;

        e.Authenticated = false;

 <authentication mode="Forms">
      <forms name=".ASPXFORMSAUTH" loginUrl="~/Ware2Login.aspx" protection="All" timeout="30" path="/" ></forms>
      <deny users="?"/>

Web Deployment Projects wont split dll's



When i try to build my Web Application project using the Web Deployment Projects the dll's aren't splitting into seperate asemblys as i have set it to.

My output look like this:

------ Build started: Project: ClassLib, Configuration: Release Any CPU ------
ClassLib -> C:\Users\Heu\Desktop\SBCms_Release_1_0\ClassLib\bin\Release\ClassLib.dll
------ Skipped Build: Project: SBCms Website, Configuration: Release Any CPU ------
Project not selected to build for this solution configuration
------ Build started: Project: SBCms Website.vbproj_deploy, Configuration: Release Any CPU ------
if exist ".\TempBuildDir\" rd /s /q ".\TempBuildDir\"
C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_compiler.exe -v "/SBCms Website.vbproj" -p "C:\Users\Heu\Desktop\SBCms_Release_1_0\SBCms Website" -u -f .\TempBuildDir\
Running aspnet_merge.exe.
C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\aspnet_merge.exe .\TempBuildDir -prefix test_ -a -copyattrs
aspnet_merge : warning 1013: Cannot find any assemblies that can be merged in the application bin folder.
Successfully merged '.\TempBuildDir'.
if exist "C:\Users\Heu\Desktop\SBCms_Release_1_0\SBCms Website.vbproj_deploy\Release\" rd /s /q "C:\Users\Heu\Desktop\SBCms_Relea

how to upload files (5MB-50MB) into sql server 2008 by using filestream

Hi!i have some files, and i need to upload these files into sql server 2008 by using filestream.lets take table name as custfiles,              columns are fileid,filename,filepath,filesize.1.how to create table using filestream?2.how to insert file (record) into table from .net environment?3.how to retrive that file from .net environment?please provide related code....THANS FOR ANY HELP

How to serialize a File using Filestream

Is there a way to serialize a file using File stream. If no how it can be done Any one please help

Store XML in XML type field or using FILESTREAM

(Posted this in Database Design, but then thought I should post here as well)   Hi All,   I am trying to figure out what would be the best method for storing xml documents in the db...if we should use an XML type field or if we should use the newly introduced FILESTREAM? We would have a need to shred those documents for queries and possibly use the FULL TEXT SEARCH to allow for user defined searches on those documents.  Does anyone have any thoughts on either approach for SQL server 2008?    Always apprecaite the input I get on this forum...very helpful.   --B

FILESTREAM in sql compact

I'm try to create a table that contains blob(in sqlce case, it's IMAGE) and using the FILESTREAM attribute 1) although i do find the doc on sql server 2008 ( e.g. VARBINARY(MAX) FILESTREAM ), but i couldn't find any on sqlce. I did try using IMAGE FILESTREAM, but it didn't work. Any idea? 2) From the doc., sql server 2008 seems to create a file in the file system. However in sqlce, does it mean any insertion to this table, will lead to creation of a file in the filesystem? 

close pop up and refresh main page after popup close

I am working on a application in which When user clicks on a button  he should be redirected to facebook login page and after successfull login he shud be reirected back to my page. It all is working fine but now I have to do like thiswhen user click on the Button the the facebookbacklogin page shud be opened in popUp and when login is done successfully the popup window shud be closed and the main page shud be refreshed. anf If user is already login the popup window shud not be opened.How can i do this..How can I KNow that a popup window is opened and how can I close that??How to refresh when popup window is closed.I ahve to do like on this site..http://blippy.com/

close ColorBox after from submit

I'm looking for code examples on how to close ColorBox modal window with a click of a submit button of a contact form inside the modal dialog, Thanks...

list webpart, not using the sourse url, but referring back to the library view on close.

i have a webpart which brings a list in to my front page. -when user clicks, it shows  the item, and when he clicks on close,it takes him back to the library view. not back to the page,from where the request has initiated. we are using f5 load balancer, and our webapplications are extended. is there somesetup i am missing, so that i can make the sourse url's refer back to the originating page.        
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend