|
Just below the message there is 'Rate this message' at right corner. Thanks for voting
|
|
|
|
|
I thought you were going to vote for my previous reply.
|
|
|
|
|
Thanks man,
Still I am having a problem.
I can't open another instance of the same file for reading, I get an exception:
The process cannot access the file 'C:\Logs\log 2007-11-17_part1.log' because it is being used by another process.
the code I used to open the first file and the second file is as follows:
first:
try
{
_fileController = new FileStream(_fileName, FileMode.Create, FileAccess.Write, FileShare.Read);
_fid = new StreamWriter(_fileController);
}
second:
fsArr[index] = new FileStream(fileName, FileMode.Open, FileAccess.Read);
How come I receive the error????
|
|
|
|
|
-- corrected 17-NOV-2007
IMO you should explicitly set FileShare values for all parties.
Either allow Read (if there are no writers), or ReadWrite (if at least one party will be
writing, your case).
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use PRE tags to preserve formatting when showing multi-line code snippets
|
|
|
|
|
First of all, the code you use to create a FileStream object creates new file so the second instance of your application will try to create file which was created by first instance and not open for reading.
Secondly, according to MSDN FileShare.Read: "Allows subsequent opening of the file for reading. If this flag is not specified, any request to open the file for reading (by this process or another process) will fail until the file is closed. However, even if this flag is specified, additional permissions might still be needed to access the file."
Finally, here is a solution for your problem: Simultaneously Write to and Read from the same file[^]
|
|
|
|
|
Hi Giorgi,
First of all, the code you use to create a FileStream object creates new file so the second instance of your application will try to create file which was created by first instance and not open for reading.
my second instance is only creating a new fileStream that will open an existing file(the one created before) for reading.
at list that is what I understand of it. please feel free to correct me if I am wrong.
thanks.
|
|
|
|
|
thank you very much Georgi,
the link you provided me indeed did the trick.
You were a lot of help to me.
|
|
|
|
|
Hello everyone,
I have what should be a relatively simple C# .NET 2.0 IE BHO that I am really struggling with. The goal of the BHO is to provide a hook when the users opens a web-page the HelloWorld! message appears.
I am using Visual Studio 2005 Profesional Edition and do the following:
1- Build Solution (F6)
2- Fire an Internet Explorer (IE)
3- (From Visual Studio) Debug -> Attach to Process...
4- Select the Internet Explorer (IE) that was started in 1.
5- Attach
At this point I can see in the StatusBar loading message for verious files.
If I am not mistaken at this point my simple BHO should be attached to the Internet Explorer (IE). when I move from the webpage to other pages I expect for the HelloWorld MessageBox to pop-up once the website is loaded. But sadly, nothing happens!
The codes are:
IObjectWithSite.cs
using System;
using System.Runtime.InteropServices;
namespace WebWatcher
{
[ComVisible(true),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown),
Guid("FC4801A3-2BA9-11CF-A229-00AA003D7352")]
public interface IObjectWithSite
{
[PreserveSig]
int SetSite([MarshalAs(UnmanagedType.IUnknown)]object site);
[PreserveSig]
int GetSite(ref Guid guid, out IntPtr ppvSite);
}
}
BHO.cs
using System;
using System.Collections.Generic;
using System.Text;
using SHDocVw;
using mshtml;
using System.IO;
using Microsoft.Win32;
using System.Runtime.InteropServices;
namespace WebWatcher
{
[
ComVisible(true),
Guid("8a194578-81ea-4850-9911-13ba2d71efbd"),
ClassInterface(ClassInterfaceType.None)
]
public class BHO : IObjectWithSite
{
private SHDocVw.WebBrowser webBrowser;
public void OnDocumentComplete(object pDisp, ref object URL)
{
System.Windows.Forms.MessageBox.Show("HelloWorld!");
}
#region WebWatcher Internal Functions
public int SetSite(object site)
{
if (site != null)
{
webBrowser = (SHDocVw.WebBrowser)site;
webBrowser.DocumentComplete += new DWebBrowserEvents2_DocumentCompleteEventHandler(this.OnDocumentComplete);
}
else
{
webBrowser.DocumentComplete -= new DWebBrowserEvents2_DocumentCompleteEventHandler(this.OnDocumentComplete);
webBrowser = null;
}
return 0;
}
public int GetSite(ref Guid guid, out IntPtr ppvSite)
{
IntPtr punk = Marshal.GetIUnknownForObject(webBrowser);
int hr = Marshal.QueryInterface(punk, ref guid, out ppvSite);
Marshal.Release(punk);
return hr;
}
#endregion
}
}
How can I see what files are been loaded when I attach the codes to the Internet Explorer? Is there any particular setting that I should set the Visual Studio to inorder ro be able to get result? Your help is greatly appriciated. Thank you very much and have a great weekend.
Khoramdin
-- modified at 12:51 Saturday 17th November, 2007
|
|
|
|
|
From the number of posts on this subject you seem to be over your head. Possibly its time to give it up and try another project.
only two letters away from being an asset
|
|
|
|
|
Hello Mark,
Thanx for your reply. Now, I know that my messages can be read by other! *wink* By the way, if it bothers you so much that I post here, I surly can stop and take my postings and problems to another forum since I don't mean to upset anyone.
Since you have been readin my posting, then you should know by know, that they are on the same subject but as I am spending more time reading about the issue, they are changing since I feel as I am getting closer to the source of the problem.
I was wondering if you got the MVP title by very same approach of moving to the next topic once you are stuck on one?!!! *wink*
Since we are on the same topic, let me ask you this. When a Class Library is Attached to a running process, then I guess I should NOT be able to delete the dll file since that file should be loaded and used with the running poccess? In my case I can delete the WebWatcher.dll file and that makes me think if the file is actually been attached! What are your thoughts on this? Any information would be appriciated, mate.
Happy thanx-giving, mate.
khoramdin
-- modified at 18:39 Saturday 17th November, 2007
|
|
|
|
|
Khoramdin wrote: I was wondering if you got the MVP title by very same approach of moving to the next topic once you are stuck on one?!!!
I'm not stuck, you are.
Khoramdin wrote: I surly can stop and take my postings and problems to another forum
Bye.
only two letters away from being an asset
|
|
|
|
|
hi all
I have found code that adds url pattern in the internet explorer (IE) Security Zone (Trusted Site) by implementing [code]IInternetSecurityManager [/code] interface.
now I want to change programmatically security level of trusted site that is like enabling or disabling ActiveX control and plugin etc.
please tell how can i do that.
thank u....
destined to win
|
|
|
|
|
I just install vs2005 on Vista,
--updated sp1 of vs, also
--sp1 of Vista for vs2005,
set the permission level on shortcut,
running as an admin,
But it still asking permission from admin ,
I know its not C# question ,
|
|
|
|
|
humdumof wrote: I know its not C# question
...then why did you ask it in the C# forum?
There is a Visual Studio forum on this site. It would be more appropriate to ask your question there.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
i need to set one image to tree view nodes and another image to inner sub-nodes
i am able to set image to node that are same to nodes and sub nodes but unable to set different image to inner sub node.
|
|
|
|
|
Define the images that your TreeView control uses by setting its ImageList property.
Set which image in the ImageList each node uses by setting the ImageIndex or ImageKey properties on each TreeNode object.
Read the documentation[^] for more information.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
I am developing an window application and in am facing a problem in getting image in list view control
--------------------------
Name| image| age
--------------------------
i want to show small image icon in second columns data.
|
|
|
|
|
Have a look at this article[^].
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
how i can print form?
123
|
|
|
|
|
|
Abhijit Jana wrote: One is enough
Why u have post same question three times????
I think its CP going slow. Yesterday i clicked post, and nothing happened. So i clicked it again, and the page eventually loaded with my message posted twice.
My current favourite word is: PIE!
Good ol' pie, it's been a while.
|
|
|
|
|
how i can print form?what i can use for print form?
123
|
|
|
|
|
how i can print form?and what i can use for print form?
123
|
|
|
|
|
Hai everyone,
I am using the following code in my application which is giving an error.please help me .
objMenu.objForm = this;
this.Menu = objMenu.LoadDynamicMenu();
Error 1 Cannot implicitly convert type 'object' to 'System.Windows.Forms.MainMenu'. An explicit conversion exists (are you missing a cast?)
santosh.
|
|
|
|
|
seems that LoadDynamicMenu method returns am object.
so you need to cast it like:
this.Menu = (System.Windows.Forms.MainMenu)objMenu.LoadDynamicMenu();
|
|
|
|