|
I recommend that you read about Regular Expressions[^] in the .NET Framework SDK.
You really don't need to search 3 times, if I understand your logic correctly. You just need to find Word1, Word2, and Word3 one after another:
Regex re = new Regex(@"\bWord1\b.*\bWord2\b.*\bWord3\b");
Match m = re.Match("This is a sentence with Word1, then Word2, and followed by Word3.");
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]
|
|
|
|
|
I would like to exercise the article "Your first C# Web Service", By Chris Maunder.
I am using XP and I have IIS turned on. When I try to create a Web Service via the Microsoft Visual Studio .Net 2003 I get the error.
‘Visual Studio cannot create or open the application because the Web server on this computer is not running. Start the Web Server before proceeding.’
The directions under the help button direct me to
‘On the Web server computer, open Control Panel and then choose Internet Services Manager.’
I do not have an option labeled ‘Internet Services Manager’. I have downloaded the Microsoft .NET Framework 1.1 plus its patches.
Does creating a Web Service require me to run Windows 2003 Server or something like that?
Thanks
|
|
|
|
|
Look under Administrative Tools in Control Panel, or just open a command prompt and type:
net start w3svc
Good luck.
The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’
|
|
|
|
|
Thank you.
This command results in a system error 1717.
I did attempt all the suggestions in the MSDN Help. I think I am missing a Windows Component, but I am not sure what or how to get it.
thanks
|
|
|
|
|
If this ain't too late.. goto add remove components in control panel and install IIS.. then ul find it in Admin tools in control panel
|
|
|
|
|
|
Try this one.
Response.Write("" +
"'www.codeproject.com','','toolbar=no,location=no,directories=no'); " +
"<" + "/" + "script" + ">" );
Dabuskol
|
|
|
|
|
You should really consider using Page.RegisterClientScriptBlock or Page.RegisterStartupScript to write to the beginning or end of the document (the page <form> , actually), respectively. This allows you to specify a key so that the script is not written more than once (which, depending on what you do, can lead to script errors). This is especially handy when designing controls that need to generate script in their containing page and you can't be sure just how many a user might add to their page.
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]
|
|
|
|
|
Thank you. I tried to use the Page.RegisterClientScriptBlock or Page.RegisterStartupScript and it works the same. I changed my codes already.
/Dabuskol
|
|
|
|
|
It doesn't actually work the same in that you can key a particular script block so that it only gets written once. If you simply use Response.Write (or something similar) than you'll have trouble knowing programmatically if you already wrote it, especially when your controls are contained within a page.
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]
|
|
|
|
|
Hi folks,
Do u guys know how to write a piece of code to check if a user has full access to a shared directory?
Thanks a bunch,
|
|
|
|
|
The simplest way is to just try to write to the directory. Checking the actual access control list (ACL) isn't necessary and does add complexity to your code. And until .NET 2.0 adds easy object-oriented support for ACLs, either you have to rely on what few (rather bad, IMO) implementations exist for .NET 1.0 or 1.1 or write your own.
A simple example follows:
try
{
using (FileStream file = File.Create("\\computer\share\test.dat"))
{
test.WriteByte((byte)1);
}
}
catch (UnauthorizedAccessException)
{
MessageBox.Show("You do not have the necessary access.", "Access Denied");
}
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]
|
|
|
|
|
I have created a DotNet DLL which needs to be accessed from ASP code.
The ASP code is able to run the DLL fine on my developer machine, when i migarte the code to Acceptance Server, the Creation of my DLL is failing.
All i am using is Regasm, to register my dll (which is not Strongly Typed).
I am keeping the copy of my dll for it to access from asp code where it exists.
Any help is greatly appreciated.
|
|
|
|
|
If you mean ASP 1.0 - 3.0, then you'll need to register your assembly (which doesn't have to be strong named, but it's highly recommended) with the /codebase switch to register the path to the DLL. You do not use this switch when the assembly is placed in the GAC (which requires that your assembly is strong named).
regasm.exe /codebase myAssembly.dll In ASP make sure you always use the prog id (ex: "MyNamespace.MyClass") unless you followed the guidelines for proper COM interoperability. See my blog for details: http://blogs.msdn.com/heaths/archive/2005/03/09/391358.aspx[^].
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]
|
|
|
|
|
I have a program that has the basic webBrowser funtion.
im trying to give it the abilty of tab browsing throught the button to add new tab. i.m having troble with the name of the new broswer object. i call it tempWebBrowser when i create it then change the name to webBrowser and the number of the tab it is on. the problem is i can not get it to do anything as the name doesnt exist in the code to get it to navigate. is there away of saftly creating a controll in runtime and being able to use it in the code.
here is the code im using to create the tab and the new webBrowser.
private void newTabToolStripButton_Click(object sender, EventArgs e)<br />
{<br />
TabPage tempTabpage1 = new TabPage();<br />
int i = tabControl1.TabCount;<br />
<br />
WebBrowser tempWebBrowser = new WebBrowser();<br />
tempWebBrowser.Name = "webBrowser" + (i + 1);<br />
tempWebBrowser.Dock = DockStyle.Fill;<br />
tempTabpage1.Name = "tabPage" + (i + 1);<br />
tempTabpage1.Text = "tabPage" + (i + 1);<br />
tempTabpage1.Controls.Add(tempWebBrowser);<br />
tabControl1.TabPages.Add(tempTabpage1);<br />
tempWebBrowser.Navigate("www.google.com");<br />
MessageBox.Show(tempWebBrowser.Name);<br />
}
any help on how i can create the new webBroswer objects and then code the go button to work for them.
|
|
|
|
|
The variable name and the value of the Name property have nothing to do with each other, actually. The local variable name is simply a reference, so the following code would create 5 WebBrowser instances with different names:
WebBrowser webBrowser = null;
for (int i = 0; i < 5; i++)
{
webBrowser = new WebBrowser();
webBrowser.Name = "webBrowser" + i.ToString();
Controls.Add(webBrowser);
} What you have to do when trying to reference a specific WebBrowser is find it by name:
WebBrowser FindBrowser(string name)
{
foreach (Control c in Controls)
{
WebBrowser webBrowser = c as WebBrowser;
if (webBrowser != null && string.Compare(webBrowser.Name, name, true) == 1)
return webBrowser;
}
return null;
}
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]
|
|
|
|
|
Thank you for the advise, i will try and use this in my program to fix the problem.
Thanks,
|
|
|
|
|
Hi!
I'm currently having a little trouble with calling the Windows XP photo printing wizard. I found this VB.NET code on the web, but when I port it to C# it tells me that vector has no add method
'create the vector COM object
Dim vector As Object = CreateObject("WIA.Vector")
' add files to the vector object
For Each file As String In files
vector.Add(file)
Next
' create the common dialog COM object, and
' display the photo print wizard
Dim dialog As Object = CreateObject("WIA.CommonDialog")
dialog.ShowPhotoPrintingWizard(vector)
vector = Nothing
dialog = Nothing
|
|
|
|
|
The .Add() method of the WIA.Vector object takes 2 parameters, a Variant and an optional Index. C# doesn't support optional parameters, so you'll have to include one in your call to .Add() . The default value for Index, according to the documentation for WIA.Vector, is 0, so:
vector.Add(file, 0);
should work.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
The problem ist that the compiler doesn't even treat the vector object correctly - it tells me that it doesn't contain a definition for the method add() (the same goes for dlg and method ShowPhotoPrintingWizard())
Here's my code:
// create the vector COM object
Type vProgID = Type.GetType("WIA.Vector");
object vector = Activator.CreateInstance(vProgID);
// add the paths of our photos to the vector
foreach(Photo.Photo p in _Photos)
vector.Add(p.Path, 0);
// create and display the COM printing dialog
Type dlgProgID = Type.GetType("WIA.CommonDialog");
object dlg = Activator.CreateInstance(dlgProgID);
dlg.ShowPhotoPrintingWizard(vector);
|
|
|
|
|
How about scrapping the Activator code and just adding a Reference to the Micrsoft Windows Image Acquisition Libary 2.0 and changing the code:
WIA.Vector vector = new WIA.VectorClass();
foreach(Photo.Photo p in _Photos)
vector.Add(p.Path, 0);
WIA.CommonDialog dlg = new WIA.CommonDialogClass();
dlg.ShowPhotoPrintingWizard(vector);
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
vector in your code is actually an object . In order to call the Add method you must do so with vector cast to the correct type. Inheritence rules do not mean that you can call a method on an object that does not actually define that method, and System.Object (or simply object in C#) does not define an Add method so the compiler is correct.
Dave's suggestion will work, but you can also use reflection to get the MethodInfo for the Add method and invoke it:
Type vectorType = Type.GetType("WIA.Vector, Interop.WIA");
object vector = Activator.CreateInstance(vectorType);
MethodInfo addMethod = vectorType.GetMethod("Add");
if (addMethod != null)
addMethod.Invoke(vector, new object[] {p.Path, 0});
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]
|
|
|
|
|
It still is not working. For some reason the addMethod is always null.
|
|
|
|
|
You should actually use the following snippet, but please read the documentation[^] for Type.GetMethod to better understand why:
MethodInfo addMethod = vectorType.GetMethod("Add", new Type[] {p.Path.GetType(), typeof(int)}); I'm making an assumption that the second parameter in your example is an int (System.Int32 ). Replace appropriate if I'm mistaken.
See Type.GetMethod(String, Type[])[^] specifically for the documentation for the method used above.
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]
|
|
|
|
|
I forgot to add that I have to retrieve the type with Type vectorType = Type.GetTypeFromProgID("WIA.Vector");, simply Type.GetType will again return a null object.
|
|
|
|