|
Did you try 'HtmlDecode' the read text?
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 1 - out now! ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
from my undersatanding the htmldecode method just replaces encoded characters such as "<" and so on to an html characters.
thats not the issue in my case.
but thanks anyway
|
|
|
|
|
Probably figured this out already but:
// read data via the response stream
Stream resStream = response.GetResponseStream();
string tempString = null;
int count = 0;
do
{
count = resStream.Read(buf, 0, buf.Length);
if (count != 0)
{
// translate from bytes to ASCII text
tempString = Encoding.ASCII.GetString(buf, 0, count);
// continue building the string
sb.Append(tempString);
}
}
while (count > 0);
Cheers, RG
|
|
|
|
|
[DllImport("Psapi.dll", SetLastError = true)]
public static extern uint GetModuleFileNameEx(IntPtr hProcess, IntPtr hModule, StringBuilder lpFileName, [MarshalAs(UnmanagedType.U4)]Int32 nSize);
[DllImport("kernel32.dll")]
public static extern IntPtr OpenProcess(UInt32 dwDesiredAccsess, Int32 inherit, UInt32 dwProcessID);
[DllImport("kernel32.dll")]
public static extern bool CloseHandle(IntPtr handle
public const long STANDARD_RIGHTS_REQUIRED = 0x000F0000L;
public const long SYNCHRONIZE = 0x00100000L;
public const long PROCESS_ALL_ACCESS = (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0xFFFF);
public const long PROCESS_QUERY_INFORMATION = 0x0400;
protected static ProcessInfo FillProcessInfoEX(ProcessInfo pi)
{
IntPtr hWnd = OpenProcess((uint)PROCESS_ALL_ACCESS, 0, (uint)pi.iProcessID);
if (hWnd == IntPtr.Zero)
{
hWnd = OpenProcess((uint)PROCESS_QUERY_INFORMATION, 0, (uint)pi.iProcessID);
if (hWnd == IntPtr.Zero)
return pi;
}
StringBuilder path = new StringBuilder(1024);
GetModuleFileNameEx((IntPtr)hWnd, IntPtr.Zero, path, 1024);
pi.sFullFilePath = path.ToString();
System.Windows.Forms.MessageBox.Show(pi.sFullFilePath);
CloseHandle(hWnd);
return pi;
}
pi is a struct. This code works fine as long the build was ran within Visual Studio 2008. But if i run just with exe, pi.sFullFilePath has only garbage on all process id. What am i doing wrong? I am using XP
Thanks for help in advance
|
|
|
|
|
I don't think you can pass a StringBuilder when a string is expected:
StringBuilder path = new StringBuilder(1024);
GetModuleFileNameEx((IntPtr)hWnd, IntPtr.Zero, path, 1024);
So I don't see how it could work at all.
|
|
|
|
|
StringBuilder can be used for marshalling LPStr, LPTStr and LPWStr types.
|
|
|
|
|
I had a some new info
i modified like
SetLastError(0);
GetModuleFileNameEx((IntPtr)hWnd, IntPtr.Zero, path, 1024);
System.Windows.Forms.MessageBox.Show(GetLastError().ToString()); Get WinApi error code
I Got error code 5: ERROR_ACCESS_DENIED
How do i grand such privilages?
|
|
|
|
|
Hey
Is it possible to use HtmlDocument, withouth the WebBrowser control?
As you see, when the document is loaded in your WebBrowser control, you can fetch
some html elements such as links, images, etc.
But I want to set my own html in the HtmlDocument, and fetch the elements I want, withouth first
using the WebBrowser to navigate to an url.
My Idea is something like this:
HtmlDocument doc = webBrowser1.Document;
for (int i = 0; i < doc.GetElementsByTagName("a").Count; i++)
{
string url = doc.GetElementsByTagName("a")[i].GetAttribute("href");
}
But withouth have to use the WebBrowser control, and just set the html like this
doc.html = "<a href='link'>link ...</a>"
Please help me
Thanks in Advance
- opx
|
|
|
|
|
Yup, you just need to get a webpage first (simply as text):
m_Client = new WebClient();
string webPage = m_Client.DownloadString(@"http://www.codeproject.com");
Then you can write this string to a HtmlDocument using the Write method:
HtmlDocument doc = new HtmlDocument();
doc.Write(webPage);
...
for (int i = 0; i < doc.GetElementsByTagName("a").Count; i++)
{
string url = doc.GetElementsByTagName("a")[i].GetAttribute("href");
}
My current favourite word is: Nipple!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
Hey, thanks allot for your reply, it worked exactly as I wanted!
But anyway, when I reopened c#, it gave me an error on "new Htmldocument();"
but il figure that out.
Thanks again!
|
|
|
|
|
Hello everyone!
My English is very poor,so if there are anything make u confused ,it's my fault.
I got a serious problem with CodeDom...here it is
I wrote a ScriptEngine with CodeDom,it can compile&run c# script file
that on the disk,something like this:
MyScriptEngine.cs
namespace HostApplication
{
public class MyScriptEngine
{
public void runScript(string fileOnDisk)
{
}
public int someElseMethod()
{
}
}
}
in the script file,i want to communication with Host Application
using System;
...
using HostApplication
public class scirpt
{
public void entryPoint()
{
MyScriptEngine.getInstance().someElseMethod();
}
}
it's possible to this?
any reply will be helpful!!
|
|
|
|
|
[Edit] Is your script class in a different namespace?[\Edit]
Yes, why not? Did you test it and got any exception?
When you're alone in the Dark, Fear will protect you...
modified on Thursday, November 6, 2008 1:59 PM
|
|
|
|
|
I already try:
1."using HostApplication" in script file -> ICodeCompiler report "can't find class or namespace..."
2.give script a namespace same with HostApplication namespace
namespace sameWithHostApplicationNamespace
{
public someclass
}
still can't access HostApplication ns class,CodeCompiler can't fint it
|
|
|
|
|
I'm using the Graphics.DrawString method to draw a string on a graphics context that has a transformation applied to it. Problem is, although the transformation gets the string to the proper location, it also scales the font size to something ridiculously large.
I know that you can force the Graphics methods to not scale line width if you create a Pen of width 0. Is there a similar way to prevent font size from being scaled?
(Not sure if this makes a difference, but the graphics context I'm drawing to is attached to a Bitmap object.)
modified on Thursday, November 6, 2008 9:50 AM
|
|
|
|
|
If you don't want to resize the text, do you really want to use a transformation? Why not just change the coordinates where you draw the text?
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
I have to check, the transformation doesn't involve scale does it? No?
Ok, the simplest method I can think of is to draw the string to a temporary buffer and the draw this buffer with the transformations you want.
My current favourite word is: Nipple!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
HI,
Can any one guide me how to run commands from a .Net Application developed in C# at Command prompt(i.E C:\>)
Any links on it would also be helpful
|
|
|
|
|
Check out this thread[^].
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
hai all,
we developed windows service and we tried to deploy this using installer Class(visual studio 2005 & Custom Actions),this service properly installed in client machine ,but this service status started option is not visible,when we try to start this service manually ,we are getting bellow error,
here my service name "myservice" ,this service start type Automatic & Acount Type LocalSystem
" Could not start the myservice service on local Computer
Error 193:Ocx1 "
Thanks & Regards,
Vishnu.
|
|
|
|
|
Hi,
I am trying to open a large xml file into an xml document as follows:
string xmlFilePath = "c:\\myXMLfile.xml";
XmlDocument doc = new XmlDocument();
doc.Load(xmlFilePath);
I get the following error on doc.Load(xmlFilePath);
the error is:
{"'', hexadecimal value 0x1E, is an invalid character. Line 1116997, position 1."}
Question:
How do I find this error in the xml file and how do I correct it.
Note that this is a large file of 300 MB.
Thanks
|
|
|
|
|
Hi,
From MSDN:
XmlDocument..::.Load Method[^]
If you want validation to occur, you can create a validating XmlReader instance by using the XmlReaderSettings class and the Create method. For more information, see Validating XML Data with XmlReader.
The Load method always preserves significant white space. The PreserveWhitespace property determines whether or not insignificant white space, that is white space in element content, is preserved. The default is false; white space in element content is not preserved.
Regards,
The only programmers that are better those C# programmers are those who code in 1's and 0's |
Programm3r
My Blog: ^_^
|
|
|
|
|
If the file weren't so large I'd open it in Notepad to fix it.
I would hesitate to write a program that blindly replaces the character(s) without further investigation.
You could write a simple console program to read each line, keeping count, and display the 1116997th line (or all lines that contain invalid characters).
Fixing the problem may be more difficult. Ideally, once you know what's going on, you can provide that information to whoever creates the file and tell them that their process is buggy and they can fix it on their end (I've had to do that).
|
|
|
|
|
|
Hi,
I have written a small reporting application which makes use of Microsoft.Office.Interop.Excel.dll and OFFICE.dll
The application retrieves data from a database and creates excel charts based on the data. It runs fine on my development machine where I have got Ms Office installed. The problem is that it needs to run on a DB Server so that it can execute as part of an SSIS package, however company policies do not permit the installation of MS Office on the servers.
I have got the dll's and included it in the bin folder of my project and then referenced them by adding reference and then browsing to the folder where they are located, instead of adding a COM reference in Visual Studio, however it still does not work.
I have read on other forums that you must have Office installed for it to work or does somebody here possibly have a solution
Kind Regards,
Robert
|
|
|
|
|
No, if you want to use their dlls then it must be installed.
I'm pretty sure (could be wrong though) that MS do not give permission for those dlls to be redistributed, so by doing so you may be breaking the law.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|