windows application html page problem.
-
I have a windows application in c#. I am required to create an html file and save on a certain directory. At the moment I am writing the file using streamwriter. But I do have a problem with the images in the file in deployment. I notice that I have available when I add an item to the project to add html page. Does anyone know if that can be dynamically altered? or anyone have a better way to add an html page? thank you tephra
-
I have a windows application in c#. I am required to create an html file and save on a certain directory. At the moment I am writing the file using streamwriter. But I do have a problem with the images in the file in deployment. I notice that I have available when I add an item to the project to add html page. Does anyone know if that can be dynamically altered? or anyone have a better way to add an html page? thank you tephra
-
drey1 wrote: I notice that I have available when I add an item to the project to add html page. Sorry tephra, could you make that clearer?
Just to test, I created a simple html page and inserted a gif image. I was able to view it in a browser. However, at first view, I can not do anything else with it. It seams static. I do not know how I can dynamically add any thing to it. I am not sure that is the right way to go for me. ie. I am trying to create an index html file with links to PDF files, and those files will always change. So the html has to be dynamic. thank you
-
I have a windows application in c#. I am required to create an html file and save on a certain directory. At the moment I am writing the file using streamwriter. But I do have a problem with the images in the file in deployment. I notice that I have available when I add an item to the project to add html page. Does anyone know if that can be dynamically altered? or anyone have a better way to add an html page? thank you tephra
You need to use relative paths in your HTML file that you're writing. I suggest using the Microsoft way of doing it, which is what happens when you save a page from Internet Explorer using the default settings: the HTML page is saved to disk and a folder is created with the same name and "_files" appended. In that directory are all the files that can be resolved (images, script files, etc.). When the HTML file is saved the path to those linked files are changed to a relative path - relative to the document, like so: filename_files/img1.gif filename_files/img2.jpg Try it. Save a document with images to disk and examine both the file and the folder with the same name. Using the same convention is consistent with other applications that use MSHTML (including IE, Word, FrontPage, and more), as well as other third-party libraries that want to provide a consistent user interface. Windows XP and newer platforms also allow users to manage both the HTML file and related folder as a single unit. How you alter it is by parsing the text as you write it and changing what gets written, then skipping that portion of the text you're writing. You could also modify it before saving. It really just depends on your requirements and if you can modify the in-memory document. This posting is provided "AS IS" with no warranties, and confers no rights. Software Design Engineer Developer Division Sustained Engineering Microsoft [My Articles] [My Blog]