473,378 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

C# application/octet-stream event

20
Hi,

I am facing a problem regarding the application/octet-stream.I have written a code that downloads a file stored in the App_Data folder to C:/files/ folder and now what problem I am facing is that when I download the file and open it, it opens from the temporary files folder rather I need it from where I have downloaded the file so that when I click the save button of the opened file it will be saved in the current location. Here's the code that I have written.

string str = Server.MapPath("App_Data/" + ListBox1.SelectedItem);
FileStream fs = new FileStream(str, FileMode.Open, FileAccess.Read);
byte[] fileContents = new byte[fs.Length];
fs.Read(fileContents, 0, fileContents.Length);
fs.Close();
FileStream fw = new FileStream("C:/files/" + ListBox1.SelectedItem, FileMode.Create, FileAccess.Write);
fw.Write(fileContents, 0, fileContents.Length);
fw.Close();

Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; fileName=\"" + ListBox1.SelectedItem + "\"");
Response.Flush();
//Response.WriteFile("C:/files/" + ListBox1.SelectedItem);
Response.BinaryWrite(fileContents);
Response.Flush();
Response.End();
lblstatus.Text = "File Downloaded";

Anybody have any idea on how this could be done. Is there a way to specify the path as from where the file should be loaded>
Or can the event from any other application like notepad be handled from C#

Looking forward for reply soon.
Sep 21 '07 #1
0 4062

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Matthew | last post by:
I am working on some software that uses SNMP to get information from routers and switches. I am using the pysnmp module (v2.0.8) to do the snmp part. The problem that I am having is that when I...
3
by: Amit Dedhia | last post by:
Hi I am developing a Dot net application (involving image processing) on a uni processor. It works well on my machine. I then take all my code on a multi processor, build and run the application...
1
by: AstroDrabb | last post by:
I am trying to update some Active Directory attributes in C#. The C# app creates new computer objects and then populates some attributes. However, I am having problems with one attribute named...
1
by: Guoqi Zheng | last post by:
Dear sir, I am not fully understand the meaning of octet. For example, if I have a string contains unicode data of some Chinese characters, how can I convert it to an array of octet? Thanks...
6
by: Josef Brunner | last post by:
Hi, I published my application (VS 2005) and am now trying to install it when I get this error message. It worked before...even on a different machine. Here is the detailed description: ...
9
by: jeff | last post by:
Hi All. I realize that when my Deployed winforms application starts, Windows needs to load the .net 2 framework before control is given to my application.... Is there anyway to either ... -...
7
by: wenmang | last post by:
Hi all, I have a confusion for representation of hex number: For an unsigned long long number, its max value is: unsigned long long maxNum = 18446744073709551615; if I do: printf("max uint64_t...
6
by: itgaurav198 | last post by:
Hi, Is it possible to convert a string in "Binary Octet String".?Also, if possible, please make clear what "Binary Octet String" is. Thanks
2
by: miltizem | last post by:
Guys i'm using a software to monitor the signal over noise factor of a traffic ... The result is given under two formats .. First an octet string Second a decibel number my question how can i...
2
by: DragonLord | last post by:
Hi guys, I am curently working with ADAM and AZMAN and I would like to store the users passord in the ADAM database. However it is of type Octet String. Being knew to the world of C# I have no...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.