How to open any file in a iframe - c#

i am using a iframe in my web page. I want to open a file c:\Dir\SubDir\xyz.doc inside a iframe.How to do this ? I checked out many sources ,all of them specified to give the source of the iframe to the path by adding the code.Its not working for me. Here is my code
iframe1.attributes["src"] ="c:\\Dir\SubDir\xyz.doc"

assuming you want to open a file on the client's computer, you would need to use a file URL, such as "file://c|/Dir/SubDir/xyz.doc". that said, it still may not work correctly for various reasons (probably primarily security-related).
if my assumption is wrong and you want to display a file on the server, you still need to use a URL and not a file path, meaning you'd have to have the file somewhere under the document root: "../Dir/SubDir/xyz.doc" for example.
then there is the strong likelihood that a .doc file will not render correctly on a webpage.

<iframe src="test.doc"></iframe>
above example is working in my environment, cause I put file inside my project folder and access that file from there..
you can not open any file out side of your project folder.... So please keep this in mind.
#jcomeau_ictx is right you cannot open .doc file in browser but yes it will ask you to save file, if you put in iframe..

Related

How to cache web to read offline in webcontrol window phone

I'm using to load website follow code
webContent.Navigate(new Uri(linkURL));
I want to cache all content and html tag, style, js in web to read offline.
I tried download html source, file css and js using Webclient and replace these file to html resource then save to file "index.htm" but not good.
Can you find the way to resolve this issue? thank you.
The only way to do this is to download ALL the relevant files (including those referenced inside the HTML. eg. images, css, js, etc.) and save them ALL to Isolated Storage with appropriate similar file and folder structures.
The important point is that you also need to update all the paths within the content so that they point to relative paths that match where files have been saved.
You can then load the HTML from IsolatedStorage.
This is potentially a lot of work. I'd recommend exploring other options if possible first. Also remember to manage the files stored in IsolatedStorage appropriately so you don't just keep adding files there indefinitely.

Including a .SWF file in a C# Webform

I'm currently working on a project where i need to include a application page for users. I need the users to access few .SWF flash games through this page. I created a folder named applications in the Application and imported the .SWF files into that. After that I tried directly linking them using a hyperlink on my page, but they don't seem to open :/
am i missing something? or is there something else i need to do before that?
Would really appreciate it if you can help
Thank you
I don't think you can just hyperlink to your .swf file. According to this site, and your using Dreamweaver or FrontPage, you can just insert it from the Insert menu (or something of the kind). If you aren't using either of those two, you can edit you .swf file in Flash and choose "Export as HTML" from the file menu (or where ever it is) and then just copy the source code of the resulting file to your webpage.
Normally, you should be able to open .swf files directly in your browser, although embedding the swf into your html is often a good idea, you don't have to.
If the url in your address bar shows an adress ending with '.swf' you can test if a swf has loaded by right clicking in your browser window, if you see the flash context menu (zoom in, zoom out, etc) Your swf has loaded.
If your swf has loaded, but nothing else happens, there can be many other reasons for this.
Where did you get the swf game files? If you copied them from another site it's very likely that the swf is supposed to load other files (game assets (images), settings (xml) etc) before the game can be played.
Sometimes the execution of (actionscript) code in a swf is triggered by script in the html page it is embedded in.
It's not entirely clear what you are trying to do....

Open a file when it downloads with HttpContext

I have a handler that I call when a link gets clicked. This handler gets the file contents from the DB and writes the contents to context.Response. I'd like to open this file as well along with it getting downloaded. Is this possible?
You have no control over browser's behavior. It will either open in browser OR display open/save dialog.
You may try to render custom page with HTML view of the file and automatically trigger second download from that HTML page to force open/save dialog.
no. it is not.
if its a bitmap file - then maybe becuase it doesnt have to be fully downloaded...
but forget about it.
it is not the right way.
you cant open a file while it is being downloaded - its a filesystem - restriction

Opening a file at a location where I encounter a hit

I am using ASP.Net MVC with C# and SOLRNET for my search tool. The files I index include .pdf files, word docs, excel etc...
I am able to search and retrieve all the docs with a hit. Now the problem lies in opening the files with a hit.
When I open the file, it should open at the location where the hit is encountered. How do i manage this? It will be even more helpful if I can highlight the hit inside the opened document?
Please help me in solving this.
It depends on the file type, or more precisly it depends on the plugin/tool used by browser to render the document
For example, for pdf you can specify on which page to open using following
<a href="document.pdf#page=123">
Word/Excel is a bit more complicated, I think there is no direct URL support, but you could in theory equip a document with AutoOpen/Exec macro which will auo-search for and highlight hits for user
All in all, there is no universal solution.

Read the first line of a file from memory

I have a tab delimited text file that I need to upload to a secure folder for SSIS to import into SQL Server. The file will be uploaded by an external user VIA a web app.
My challenge is that I need to check this file for some things before I am allowed to let it go to the secure folder. Namely I need to make sure the user has a specific column.
I can do this if I save the file to a folder in the web app. However the nature of the data in the file is such that we do not wish to place this file anywhere other then the secured folder. I also can not place it directly to this folder because the SSIS package is set to trigger as soon as the file shows up there.
What I need to do is find a way, if there is one, to parse the file in memory and if it passes all the checks, upload it to the secure folder.
I'm using C#.NET and the FileUpload Control.
My search so far has included all kinds of information but they all require saving the file somewhere first and then working with it.
Thank you so much for your time. If anybody can point me to an object or some code I can check out I would be most grateful.
Rather than calling SaveAs, use the FileContent property to access the contents of the file as a Stream, then you can do whatever processing is required before you save it manually.
For example, something like this:
string data;
using(StreamReader reader = new StreamReader(fileUpload.FileContent))
{
data = reader.ReadToEnd();
}
The data variable now contains the contents of the file as a string. You can do whatever processing you like, then save it (or not) to the appropriate location.

Categories

Resources