Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I want have my azure . NET web application upload a file, manipulate it and then download the changed version.
Should I use blob storage? I don't actually need to store the data in the file.
Should I use blob storage?
That depends on what your requirements are.
I don't actually need to store the data in the file.
Given this fact, you probably don't need to use blog storage.
You could simply do something like this:
var postedFile = Request.Files[0] as HttpPostedFileBase;
var stream = new MemoryStream();
postedFile.InputStream.CopyTo(stream);
// work with MemoryStream
...
//return your file which could be different based on mvc, web forms or whatever
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I took a look at the ZipFile class but it does only support single files. So my question is: Is there any way to extract multipart zip files without relying on 3rd party tools?
Simple answer is not unless you write one yourself, the .Net compression system is geared towards streams not files, and as a stream can be a file, memory space, network traffic or a data feed from a device, enforcing file compression onto them would be a very bad thing
I tend to use SharpZip, its a free opensource library that handles some of the most common compression formats
Update:
looks like if you'rr using .net4.5 or higher ms has added the ZipArchive which allows you access directly to the windows zip manager (thanks to spender)
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
I want to open a free pascal or turbo pascal file that has a .pas extension from a wpf application.
If you want to open the editor associated with a file, then just do:
System.Diagnostics.Process.Start(path);
Where path is the FQN of the .pas file.
Basically, Windows will look for a program that is registered to view/edit the type (extension) of file when its not an executable. It will then create a new process passing the file name to the viewer/editor. See http://support.microsoft.com/kb/307859 for more info.
OR if by open, you mean making your WPF application the default program associated with .pas files. Then you need to make a few registry changes. This SO question provides the details.
OR if by open, you mean reading the file, then try System.IO.File.ReadAllLines or System.IO.File.ReadAllText. More info at File method.
string[] lines = File.ReadAllLines("C:\input.pas");
For more information about File class, have a look at the resource here:
http://msdn.microsoft.com/en-us/library/system.io.file%28v=vs.110%29.aspx
May be below code would help
using System.IO;
FileStream fileStream = new FileStream(#"C:\input.pas", FileMode.Open);
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
So, I'm a newbie using MVC and Razor - I do have some C# experience, however.
That being said, I need to make a simple web-app and the project specifications require server-side data to be stored in CSV. Everything I've researched online involves uploading a CSV file to the server, or letting the user download one. This is not what I want.
This is what I need help with:
1) Appending a new line to an existing server-side CSV file between user page directs/requests.
User submits page --> server appends data to server-side CSV --> User gets redirected to new page
2) Iterating through a static CSV file and presenting the data in a table.
User requests page --> Server iterates through CSV and dumps line data into a table --> User gets page with table full of data
Any ideas where to start with this?
Decide where you want to store the file, here is one of the paths:
string csvPath = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, "App_data") + "\info.csv";
In the controller action use regular File IO APIs (http://msdn.microsoft.com/en-us/library/system.io.file(v=vs.110).aspx) to manipulate the file
While this may answer your specific question, this wouldn't scale when you have many front ends, multiple users trying out your site,... Suggest going with a backend DB to store such info. You would need to use locks solve the latter if you are not going to use DB.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
The site provides links as http://www.example.com/download.php?id=53979 . I know that this is a pdf file and want to download it via a C# program. Is this possible and if yes, how?
In order to download a file, you simply need to use the WebClient object like in the question referenced above:
using (var client = new WebClient())
client.DownloadFile("http://www.datasheet4u.com/download.php?id=53979", "datasheet.pdf");
What makes your case slightly different has nothing to do with the server being written in PHP or anything like that. The link you provided (http://www.datasheet4u.com/datasheet/L/M/7/LM741_NationalSemiconductor.pdf.html) appears to be checking Referer headers when serving the file. This is likely some attempt on their part to prevent what you're trying to do, but it doesn't actually prevent it.
All you need to do is add a Referer header to the request. Something like this:
using (var client = new WebClient())
{
client.Headers.Add("Referer","http://www.datasheet4u.com/datasheet/L/M/7/LM741_NationalSemiconductor.pdf.html");
client.DownloadFile("http://www.datasheet4u.com/download.php?id=53979", "datasheet.pdf");
}
The method for downloading the file is still the same. The server just requires that you send an extra piece of information in the request.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I need to write an employee maintenance program (in C#) that can add, change and delete from a text file. I have the HTML all put into an .aspx file but I have NO clue on how to set it up to read from a text file and populate the input fields with the employee to maintain.
If I could get some insight on how to read a text file and populate the input fields(form fields) that would be great. Even a link that explains it since I haven't been able to find one. The text file will have to have a record ID as the first field so I know which one to grab for editing(to display) or deleting.
There's a toolkit of functions to manipulate files in the system.io.file class. That's a reasonable start for the project.
You might also consider using a database instead of a text file. They're designed to handle storage and retrieval of data that changes a lot. A text file is doing it the hard way.