Home Pass file to another project in ASP.NET

# Pass file to another project in ASP.NET

Kajbo
1#
Kajbo Published in 2018-02-14 09:23:45Z
 I'm trying to create simple app for editing .xml files. I have created another project within one solution to which I'm trying to pass file, where I would like to edit and save it. But is that possible? I have tried to import System.web and then request HttpPostedFile as parameter of one function, but VS do not recognize such type there. What am I doing wrong? Alternatively, what is better way to pass file from one project to another?
Chriz
2#
 There are multiple ways to realize passing data between different classes. One way is to pass it with a Stream, as System.File.Open (MSDN) already gives back a FileStream. With streams you need to be careful with the handling of opening, closing, reading etc (see using). Another way is by simply passing the path of the file as a string and open it elsewhere. But as you are trying to use a HttpPostedFile-object, I guess you're working on a project running on 2 different machines. You should read into streaming data, and with streaming it's irrelevant if you got the data from a file, a request or even another stream. Edit: It seems your main first problem here was that the class HttpPostedFile was in a assembly you didnt referenced before. You can get tips for situations like these by pressing Ctrl + .. VS suggests you things like creating a class for unknown objects or, if it's a common known object, adding references.