In my a c# program, I want to load a google map which is a html file stored in my local disk but it failed.It says that the application have something wrong with internet connection. Here is my screenshot and some code
private void 加载地图ToolStripMenuItem_Click(object sender, EventArgs e)
{
//webBrowser1.Navigate("D:/GoogleMap/GoogleMap.html");
webBrowser1.Navigate("D:/exercise/源代码/windows监控端/TestGoogleMapGps/TestGoogleMapGps/GoogleMap.html");
}
Well normally your local machine uses the backslash, not the forward slash, so try:
webBrowser1.Navigate(#"D:\GoogleMap\GoogleMap.html");
webBrowser1.Navigate(#"D:\exercise\源代码\windows监控端\TestGoogleMapGps\TestGoogleMapGps\GoogleMap.html");
Although, I'm not entirely sure that's the solution you're going for.
Related
I just want to Code an Launcher for the Game i currently making, but i ran into an Problem and i am an absolutely beginner as a Programmer.
Currently i have a Start Button with looks like this
private void startbtn_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("C:\\Users\\Windows\\Desktop\\Folder\\Underfolder\\Game.exe");
}
But i try to make it Dynamic, so the Launcher can work which ever the User install the Data (There is an Installer for everything) also the launcher is located in the same directory as the Game.exe
(The Code looks weird on the Post but it is correct)
The most reliable way I've found to do this is (assuming Game.exe is located in the same path as your Launcher.exe as you mentioned in your post):
var launcherExeDirectory = AppDomain.CurrentDomain.BaseDirectory;
var gameExeFullPath = Path.Combine(launcherExeDirectory, "Game.exe");
Then you can just do something like:
Process.Start(gameExeFullPath);
Just use GetCurrentDirectory
Process.Start(System.IO.Directory.GetCurrentDirectory + #"\game.exe");
///Or
Process.Start(AppDomain.CurrentDomain.BaseDirectory + #"\game.exe");
///or
Process.Start(Application.ResourceAssembly.Location + #"\game.exe");
///or
Process.Start( System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + #"\game.exe");
I use an IAutoTamper2 to colorcode relevant requests/responses to my application based on url and other information.
This is very helpful for debugging. However when someone sends me a saved .saz file, I no longer see my helpful colorcodes. How can I apply the IAutoTamper2 logic when a file is imported.
I looked at the ISessionImporter interface but you have to start from scratch. Is there a way to inherit from the default importer and add my logic that occurs in the IAutoTamper2?
I've looked at all the documentation about extensions on the telerik website but couldn't find anything relevant. Any ideas?
I figured out how to do it. There is a OnLoadSAZ event that I can use to change loaded sessions.
This is my code:
public void OnLoad()
{
FiddlerApplication.OnLoadSAZ += HandleLoadSaz;
}
private void HandleLoadSaz(object sender, FiddlerApplication.ReadSAZEventArgs e)
{
FiddlerApplication.UI.lvSessions.BeginUpdate();
foreach (var session in e.arrSessions)
{
OnPeekAtResponseHeaders(session); //Run whatever function you use in IAutoTamper
session.RefreshUI();
}
FiddlerApplication.UI.lvSessions.EndUpdate();
}
I hope that helps someone else.
I need to add 2 type of links to existing report with c#. For exapmle:
1) http://www.google.co.il/
2) file:///C:/index.html
I added the links, but only the "http://" works. when I press the link of "file:///" nothing happens.
I've uploaded the full project (very small though) which includes the problem:
http://www.filefactory.com/file/452gsoyymalv/n/ObjectReports.zip
BTW, the "index.html" is a simple 'helloWorld' which loaded successfully when writing the path on the address bar in the browser.
Do anyone knows what additional settings should be set to make the file link work?
*Credit for the sample (without my case):
http://www.c-sharpcorner.com/uploadfile/mahesh/reportviewerobject04172007111636am/reportviewerobject.aspx
AFAIK this is disabled for security reasons - the ReportViewer is NOT a complete browser...
You can try to circumvent that limitation by handling ReportViewer.Hyperlink event yourself... can't try it myself right now, but that's about the only option that can possibly work IMHO...
This is the detailed solution (main idea suggested by #Yahia):
First, I created the event handler:
public void HyperLinkReportHandler(Object sender, HyperlinkEventArgs e)
{
Process.Start(e.Hyperlink);
}
Second, I associated the event handler:
this.rvContainer.Hyperlink += HyperLinkReportHandler;
I am working on a WPF application and I wish to open sip:Username#company.com links. I am able to open mailto links using the following code:
private void btnSendEmail_Click(object sender, RoutedEventArgs e)
{
try
{
string mailURL = String.Format("mailto:{0}", UserDetails.EmailAddress);
Process.Start(mailURL);
Close();
}
catch
{
// Handle exception
}
}
Although, I am unable to open sip: links in a similar way. What I am trying to achieve is to open a new chat session with a user, like I am able to do when I follow sip: links from Outlook.
Any ideas?
Edit: I ended up using the CommunicatorAPI. Messenger.InstantMessage() seems to work for me. More info here: http://msdn.microsoft.com/en-us/library/bb787232.aspx
Using Process.Start works fine on my system (with Microsoft Lync 2010, a newer version of Communicator):
void Main()
{
Process.Start("sip:username#company.com");
}
Running the above code results in a new chat window opening. The only exception is when I enter my own user name, in which it starts composing a new Outlook e-mail message to myself. What happens when you use this (maybe also try omitting the following call to Close).
You probably need to associate a program with the "sip" uri scheme. Try this: how do I create my own URL protocol? (e.g. so://...)
if you have Lync or Office Communicator installed, they should respond appropriately to the sip: uri scheme. Also, tel:, callto: etc. For reference, the full list is here.
Is this not working for you from a WPF app? Does it work for you from a basic html page?
I ended up using the CommunicatorAPI. Messenger.InstantMessage() seems to work for me. More info here: http://msdn.microsoft.com/en-us/library/bb787232.aspx
The following code probably didn't work for you because you were trying to IM yourself.
Process.Start("sip:username#company.com");
I'm writing a tool that performs copying from USB devices to the local HD - I wonder if there is a function in C# to copy a file from one path to another?
Yes! The cunningly named:
File.Copy
File.Copy is probably OK for what you want to do, but it doesn't provide much flexibility (no cancellation, no progress tracking...).
If you need those features, you can look at the CopyFileEx API, which supports them. I wrote a .NET wrapper for CopyFileEx (and also MoveFileWithProgress), you can find it here (documentation comments are in French, sorry about that... hopefully that won't be an issue). Here's how you can use it:
void CopyFile(string source, string destination)
{
var copy = new FileCopyOperation(source, destination);
copy.ReplaceExisting = true;
copy.ProgressChanged += copy_ProgressChanged;
copy.Execute();
}
void copy_ProgressChanged(object sender, FileOperationProgressEventArgs e)
{
copyProgressBar.Value = e.PercentDone;
if (abortRequested)
e.Action = FileOperationProgressAction.Cancel;
}