I am looking to create a desktop application in C# which :
Allows the user to select a file / multiple files / folder containing files from his computer.
Upload the files selected to a PHP script (which is already equipped to handle file uploads using the $_FILES array.)
I'm a PHP developer and have never coded a single line of .NET before. So, you can assume I have no experience with .NET whatsoever.
I have looked this up online and all I seem to come up with are ASP.NET server side upload controls which i do not want. I'm looking for a client side solution. Also, will i have to make any changes in my PHP script ? The script already handles uploads from an HTML multipart form.
If anyone can help me point in the right direction of where to look, what C# controls are available which can help me create the application I need, I would really appreciate it.
The first, and simplest, way to go about this is to use any of the WebClient's UploadFile methods.
Here's some info an an example;
http://msdn.microsoft.com/en-us/library/36s52zhs.aspx
I have a feeling that this will not be enough for you, since you want to upload multiple files in a single request. The WebClient class can be used to manually build a http multipart request, which is probably your best bet.
It's a bit much to explain how to achieve this here on SO, but there are good guides out there.
Here are a couple of very to-the-point articles
http://www.codeproject.com/KB/cs/uploadfileex.aspx
http://www.codeproject.com/KB/IP/multipart_request_C_.aspx
And if you're interested in the details, or better OO design, here's an alternative (a bit harder to follow if you're not experienced with C#)
http://ferozedaud.blogspot.com/2010/03/multipart-form-upload-helper.html
I think both articles should give you enough info to get started.
Related
How can I include/embed .*chm help file in application itself (not as separate file in output)? Can it be placed in "Resources.resx" and read from there? I tried this method but it seems that it doesn't work...
Storing the chm in a resource is a bad idea and difficult to handle, deploy it as a plain file.
Changing and recompiling a CHM file is not an easy task without the associated project file (*.hhp). Therefore, the content is reasonably - but of course not completely - safe.
A user actually makes your software unusable by making changes to the installation path and help content. Updating the help topics must match the version of your app and is your responsibility.
If it meets your requirements you can think about a so-called web-based help. Upload your help to a server and add a web browser control to your application.
See also:
Best approach to implement Help feature in Windows Desktop Application - Restrict the App knowledge base to authorize access
Old stuff, but have a look at a sample for Uncompressed help here too.
I have a simple question in which I couldn't find an exact answer to, that question being:If I created an ASP.NET webpage, is it possible for someone to steal my C# source code?And if so, how can I protect my webpage's source code from being stolen/dumped/reverse engineered?
Please if you do know anything about this, as many replies as possible would be greatly appreciated! Thank you guys so very much, even if you just give me an idea on this topic! :)
Are you talking about a corporate user or a regular user?
Someone accessing your website from a web browser, like a standard user can not access your aspx/cs server side code. However if you are talking about a corporate user, if they browse to your web server and have access to your inetpub\wwwroot directory (or wherever your source resides) they have full read or maybe even write access. It all depends on the type of user, and the user security system in place for your domain, whether the person trying to get in is part of your domain and has proper privileges on your server. Also some client side scripts are exposed to user's as well.
So as far as server side scripts, users not part of your domain, and stringent security settings on your web server, are all factors contributing. But I think you mean in the context of a user just trying to access code from the web browser without any additional permissions. Which in this case would be no.
Not a complete answer but your C# code will be better protected if you use a Web Application rather than a Web Site. Your C# code will be compiled so even with an FTP access (or a direct access to the production server, if you suspect an inside threat), one won't be able to download your .cs files. Of course, one can download .dll and reverse engineer but that's something.
Read more about Web Apps vs Web Sites here : http://msdn.microsoft.com/en-us/library/dd547590.aspx
To the best of my knowledge there is not a way for someone to steal your asp code unless you allow them to see the file itself. If you view source you will see that the majority of the asp code has been changed either to html or javascript.
If I created an ASP.NET webpage, is it possible for someone to steal my C# source code?
Yes it is, there just to many ways how this can happen, vulnerability in the hosting environment, IIS exploit, your code allowing to download things etc. Just accept that your libraries (I assume they are compiled by the time you deploy) will be downloaded and protect them accordingly.
How can I protect my webpage's source code from being stolen/dumped/reverse engineered?
You cannot have an ultimate protection, but you may make life complicated for the person trying to reverse engineer it. Probably the most effective solution is to use code obfuscation. You may also want to read more general documentation on this topic, such as Design Guidelines for Secure Web Applications.
I need to get information from couple of web sites . For example this site
What would be the best way to get all the links from the page so that the information could be extracted.
Some times need to click on a link to get other links inside that.
I tried Watin and I tried doing the same from within Excel 2007 with Web Data option.
Could you please suggest some better way which I am not aware of .
Ncrawler might be very useful for the deep level crawling . You could also set the MaxCrawlDepth for specifying the same.
Have a look at WGet. It is an incredibly powerful tool for mining the content of a single page or an entire website. The options available allow you to dictate how many levels deep to follow in terms of links, what to do with static resources such as images, how to handle relative links, etc. It also does a very good job of mining pages which are generated dynamically, such as those served by CGI or ASP.
It's been around for many years in the 'nix world but executables compiled for Windows are readily available.
You would need to kick it off from .NET using Process.Start but you could then pipe the results into multiple files (which mimic the original website structure), a single file, or into memory by capturing standard output. Then you can do subsequent analysis such as extracting HREF HTML elements (if it is only links you are interested in) or grabbing the sort of table data evident in the link you provide in your question.
I realise this is not a 'pure' .NET solution but the power WGET offers more than compensates for this, in my opinion. I have used it myself in the past, in this way, for exactly the sort of thing I think you are trying to do.
I recommend to use http://watin.org/. This is much simpler than wget :-)
I made a browser program for a archive type with the .mpq extension, which is highly used in Blizzard games.
It is like an explorer but only explores files inside MPQ archives.
Now, we all know how Windows Explorer browses .zip archives and I'd love to make it open the .MPQ files with so many rich features.
Is this even possible? So it is possible...
If so, then how? Shell Folder...
Can someone please point me to an example? (C#) I can't just translate C++ to C#...
This is done via extending the shell classes. You'll need to implement the Basic Folder Object Interfaces to accomplish this.
Although it is a C++ framework, there is a framework that implements exactly what you want, and that I have adapted with success for a similar file format:
TarFolder (by the guy who developed GMail Drive).
You may also be interested in EZNamespaceExtension.Net, even if they do not support extension-based rooting (a workaround is to use URLs with specific protocols).
Finally, check out WindowsShell: it might be exactly what you are looking for !
Sorry for coming so late after the storm...
We all know that it is possible to "open" a Word document (or file from any arbitrary application) by clicking on a website link and then clicking the Open button.
I also know that, if I want to upload an application document to a web server, I must first save the document to my computer, and then go to an upload page, click a file/open button, find my saved file and upload it.
But is it possible to save a document to a website location or Url, effectively skipping the first save step and uploading the file to the web server through the Save dialog of the application, directly?
How would this be done in ASP.NET MVC?
It really depends on how complex you want to make it. This is pretty much what "web folders" offered (via WebDAV), but in general it creates more problems than it will ever fix. I don't recommend this approach.
Your best bet to make this simple is a dedicated client app - perhaps (although this is a dubious example) how Office talks to sharepoint. In a simpler example, you could create a silverlight out-of-browser application that saved via a web-service to a site using WCF or similar.
I think there is some creedence in what #Marc says. Personally I'd probably map a drive to the web site in question, if that's possible, and have a folder to upload to.
Then I'd have .Net check changes to the folder and take those files and import them into the repository, whatever that may be.
It's still an imperfect solution and I'm not sure there is a correct solution as yet.
I guess you could always write, and I can't believe I'm writing this, macros to save to the ftp location.
I'd guess you have a few choices, in no particular order:
Web service that the application can reference and upload through.
REST service (WCF or otherwise) that the application can POST to.
HttpHandler or MVC controller action that the application can POST to.
WebDAV directly to the server.
Number 3 sounds like it's closest to what you were looking for ("How would this be done in ASP.NET MVC?"). Scott Hanselman has a good article on handling file uploads in MVC on his blog.
When you implement the client, there's a little bit of a trick to that, too, since you can't just POST like usual; you have to post in multipart/form-data format. I posted a blog entry with some sample code on how to do that.