|
Regex can be horribly unreliable and a complete pain when unforeseen formats creep up. I recommend using SgmlReader[^] written by a fellow Microsoftie. HTML is, if you don't know, an SGML grammar, as is XML and XHTML (which is actually an XML grammar that only looks like HTML because it uses the XHTML namespace as the default namespace so that namespace prefices aren't required).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Hello,
I want to know, how can i enable/disable internet access to certain systems on the network ?
Is there any class/... for this ?
Regards,
Asim
|
|
|
|
|
Don't cross post acrossed Forums. It's considered very rude...
There is no class to do this. The best way to do it is a Proxy server...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hi
i am trying to make a simple web application using web services with c# web matrix
i have get the data from html page and i can print it on my aspx page
but i could not be able to pass my data to my web services
in my web services i want to send my data in access database
we i show you my code as under that i used ...
this is my html code
<html>
<head>
</head>
<body>
<form id="Form1" name="form1" action="aspx1.aspx" method="post">
<p>
</p>
<p>
First Name:<input type="text" name="fname"/>
</p>
<p>
Last Name:<input type="text" name="lname"/>
</p>
<p>
<input type="submit" value="Submit" />
</p>
</form>
</body>
</html>
this is my aspx page code
<%@ Page Language="C#" Debug=true %>
<script runat="server">
void Page_Load(object src,EventArgs e)
{
String fn,ln;
fn = Request.Form.Get("fname");
ln=Request.Form.Get("lname");
Response.Write("Your First Name is = " +"<b>" +fn +"</b>" +"<br>");
Response.Write("Your Last Name is = " +"<b>" +ln +"</b>" +"<br>");
}
</script>
<html>
<head>
</head>
<body>
</body>
</html>
and this is my web services code
<%@ WebService language="C#" Debug="True" class="my" %>
using System;
using System.Web.Services;
using System.Xml.Serialization;
public class my {
[WebMethod]
public void Add(string a, string b) {
OleDbConnection objConnection = null;
OleDbCommand objCmd = null;
string strConnection, strSQL;
strConnection = "Provider=Microsoft.Jet.OLEDB.4.0 ;Data Source="+Server.MapPath(".\\database\\t1.mdb");
// Create and open the connection object
objConnection = new OleDbConnection(strConnection);
objConnection.Open();
// Set the SQL string
strSQL = "INSERT INTO sis (fname, lname) VALUES ( a , b)";
// Create the Command and set its properties
objCmd = new OleDbCommand(strSQL, objConnection);
// here our ionsert query will execute and insertour data in the database.
objCmd.ExecuteNonQuery();
objConnection.Close();
}
}
Mazhar Hussain
|
|
|
|
|
This belongs in the ASP.NET forum.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Hello,
how could one get tree folder browser in C#, like the one that Windows Explorer uses? I looked at all examples given, and have made my own version, but I can't get it to display Network Places. I can get the names of the all volumes connected (HDD, CDs, USB disks...), but don't know how to get Network Places.
So if anyone can point me the right way....
thnx,
ajvn
|
|
|
|
|
ajvn wrote:
So if anyone can point me the right way....
Sure, you will need to P/Invoke many of the Win32 functions and structures to do so, the following should get you started.
[DllImport("mpr.dll")]
public static extern int WNetOpenEnum(ResourceScope dwScope, ResourceType dwType, ResourceUsage dwUsage, NETRESOURCE lpNetResource, out IntPtr lphEnum);
[DllImport("mpr.dll")]
public static extern int WNetEnumResource(IntPtr hEnum, ref uint lpcCount, IntPtr lpBuffer, ref uint lpBufferSize);
[DllImport("mpr.dll")]
public static extern int WNetCloseEnum(IntPtr hEnum);
[StructLayout(LayoutKind.Sequential)]
public class NETRESOURCE
{
public ResourceScope dwScope = 0;
public ResourceType dwType = 0;
public ResourceDisplayType dwDisplayType = 0;
public ResourceUsage dwUsage = 0;
public string lpLocalName = null;
public string lpRemoteName = null;
public string lpComment = null;
public string lpProvider = null;
}
public enum ResourceScope
{
RESOURCE_CONNECTED = 1,
RESOURCE_GLOBALNET,
RESOURCE_REMEMBERED,
}
public enum ResourceType
{
RESOURCETYPE_ANY = 0,
RESOURCETYPE_DISK,
RESOURCETYPE_PRINT,
}
public enum ResourceDisplayType
{
RESOURCEDISPLAYTYPE_GENERIC = 0,
RESOURCEDISPLAYTYPE_DOMAIN,
RESOURCEDISPLAYTYPE_SERVER,
RESOURCEDISPLAYTYPE_SHARE,
}
public enum ResourceUsage
{
RESOURCEUSAGE_ALL = 0,
RESOURCEUSAGE_CONNECTABLE,
RESOURCEUSAGE_CONTAINER,
}
public const int NO_ERROR = 0;
public const int ERROR_NO_MORE_ITEMS = 259;
- Nick Parker My Blog | My Articles
|
|
|
|
|
|
Hello
I am trying to use Assembly.Load function to load C# dll from the subdirectory "subdir":
a = Assembly.Load("TestSer.dll");
But it generate an error: Can't find an assembly TestSer.dll
I am using configuration file:
<configuration>
<runtime>
<assemblybinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatepath="subdir">
Can anybody help?
Oleg Chebotar
|
|
|
|
|
When you post tags in angled brackets (i.e., HTML or XML), you need to encode them (ex: < == <), or check "Do not treat <'s as HTML tags" below.
You should read Specifying an Assembly's Location[^], as well as How the Runtime Locates Assemblies[^]. The first link discusses how to use the <probing> element to specify the probing path, while the second is a general article discussing how the CLR locates assemblies (and in what order directories are checked).
Also make sure that your .config file is named the same as your application (libraries using the defualt loader do not read from their own .config files - only the AppDomain into which they're loaded) and in the same directory. So, if your application is named myapp.exe, then your configuration file should be named myapp.exe.config and be in the same directory as your application.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Thank you for the answere.
Config file is named TestAsm.exe.config (application is TestAsm.exe):
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="testdir"/>
</assemblyBinding>
</runtime>
</configuration>
"testdir" is the subdir of the directory where TestAsm.exe is located.
And one more question - why config file disappear every time I compile the application?
|
|
|
|
|
If you have a file named app.config in your project, this is renamed appropriately and copied to the target directory. If you don't, it may be deleted since target files are deleted when you rebuild. I recommend adding an app.config to our project and specifying your settings in that.
If you're debugging your application from Visual Studio, understand that your application is actually run from the target directory underneath obj, not bin (ex: obj\Debug, not bin\Debug). So, if you're copying your dependent assembly to bin\Debug\testdir, it won't be found if you're running the application - attaching the debugger or not - from Visual Studio. You need to place it in obj\Debug\testdir.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
I added TestAsm.exe.config file to the project but it doesn't work. "subdir" is placed both in obj and bin directory. All I get:
LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).
LOG: Post-policy reference: TestSer
LOG: Attempting download of new URL file:///C:/SOFT/C#/samples/TestAsm/TestAsm/bin/Debug/TestSer.DLL.
LOG: Attempting download of new URL file:///C:/SOFT/C#/samples/TestAsm/TestAsm/bin/Debug/TestSer/TestSer.DLL.
LOG: Attempting download of new URL file:///C:/SOFT/C#/samples/TestAsm/TestAsm/bin/Debug/TestSer.EXE.
LOG: Attempting download of new URL file:///C:/SOFT/C#/samples/TestAsm/TestAsm/bin/Debug/TestSer/TestSer.EXE.
Thank you
Oleg Chebotar
www.gelosoft.com
|
|
|
|
|
I said you add a file named app.config (exactly that name) to your project, and it will get renamed accordingly. If you run the application using Vs.NET, it runs from obj. If you simply launch your application you typically do it from bin. Whatever is fine so long as the correctly named file (not adding a file named app.config will not move it correctly - actually, not at all) is present in the right directory.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Thanks a lot!
It works.
Oleg Chebotar
www.gelosoft.com
|
|
|
|
|
Heath Stewart wrote:
If you're debugging your application from Visual Studio, understand that your application is actually run from the target directory underneath obj, not bin (ex: obj\Debug, not bin\Debug).
I've always known Visual Studio to run the app from bin\debug. In fact, the debug output clearly states that the .exe is being loaded from the bin\Debug path. Did I misunderstand your statement?
Charlie
if(!curlies){ return; }
|
|
|
|
|
Hey,
This is driving me up the wall!
Some one please help,please please!
Heres the situation
I have a set of 3 grids.
They bind correctly as follows
//Parent Grid
dataGrid1.DataSource=parent;
//Child Grid
dataGrid2.DataSource=parent;
dataGrid2.DataMember="Parent.Child";
//Grand Child Grid
dataGrid3.DataSource=parent;
dataGrid3.DataMember="Parent.ChildToGrandChild";
The relation works beautifully.Been working for months now.
Here is the issue:
I have to filter out data in the child grid ie dataGrid2, which in turn will affect dataGrid3 which is fine.
I have tried using the RowFilter property of the DefaultView exposed by the DataTable, but to no avail. Filter does not take effect and it renders all the rows.
These are the methods i have tried.
1. ((System.Data.DataTable) dataGrid2.DataSource).ChildRelations["Parent.Child"].ChildTable.DefaultView.RowFilter = " [FilterMeNow] = '1'";
does not work.
2. I tried setting up the filter before establishing the databinding but after the relation is set, again it wont work.
e.g. patient.DataSet.Tables[1].DefaultView.RowFilter="[FilterMeNow]= '1'";
dataGrid2.DataSource=patient;
dataGrid.DataMember="Parent.ToChild";
3. Googling it leads to me to think setting the row filter is the way to go....but nothing seems to happen. Though it works for me when i am using it on a single non-relationed datagrid.
I know RowFilter works because I have been using it for single grid all year long.
So how do i go about using it in master-child relation datagrid.
Am I just supposed to refresh the grids after they are bound, resulting in the row filter to take affect. If so, how?
Desperate plead other wise i will have to write 2 procedures, one with filtered data and one without filtered data. which to me seems absolutely horrendous, kind of defeating the whole purpose of the row filter functionality. so please rescue me from this !
Frusturated Looney Tunezez
Cheers!
<bold>Looney Tunezez
"If you build it....
.....BUGS will come!" -JB
Application.Run(new Form1(this.Dispose())); <--WHAT :wtf::confused::eek:
"Stability. What an interesting concept" - Chris Maunder
<bold>
|
|
|
|
|
I'm trying to make a program to read images from a zip, then display them. The problem is that...the way I create the instance of the zipfile makes it so no other function can access the instance. I wouldnt want to create a new instance and memorystream for each image. I don't know what to do :\ Here is some code snippiets:
------------------------------------------------
public void ShowImage(int theNum)
{
AbstractFile imageFile = zip.GetFile(zipFiles[num]);
if (imageFile.Exists)
{
using( Stream stImage = imageFile.OpenRead() )
{
pbMain.Image = Image.FromStream(stImage);
}
}
}
-----------------------------------------------
public void OpenZip(string archive)
{
ZipArchive zip = new ZipArchive( new DiskFile( archive ) );
MemoryFolder folder = new MemoryFolder( "RAM_Drive", "folder" );
zip.CopyFilesTo(folder, true, true);
int x = 0;
foreach ( AbstractFile f in folder.GetFiles(true, new NameFilter("*.jpg|*.jpeg|*.bmp|*.gif|*.png")))
{
zipFiles[x] = f.Name;
x += 1;
}
}
-------------------------------------------------------------
if ( sExt == "zip")
{
OpenZip(sFull);
ShowImage(num);
}
How can I access the zip instance from the ShowImage() function? Thx for the help.
|
|
|
|
|
you could try using the singleton pattern. Have an external singleton class hold the instance of open zip file, access the instance from both functions.
class ZipHolder
{
private ZipHolder()
{
}
private ZipArchive zip = null;
public ZipHolder Instance = new ZipHolder();
public void Open(string name)
{
zip = new ZipArchive(name);
....
}
public ZipArchive Zip
{
get { return zip; }
}
}
you can then access the Open thus:
ZipHolder.Instance.Open("myzip.zip");
and the open zip file by
ZipHolder.Instance.Zip.<exposed function="" method="" etc.="">
Gary
|
|
|
|
|
Thanks for the help However...when I try using the code I get this error:
'mrmanga.ZipHolder.ZipHolder()' is inaccessible due to its protection level
Any idea?
--- edit ---
Also, when i try making ZipHolder() public, I get this:
An unhandled exception of type 'System.StackOverflowException' occurred in mrmanga.exe
|
|
|
|
|
Hi,
Sorry I wasn't clear, and I think it lost some of the information I added in a tag.
Ok.
To open the zip file
ZipHolder.Instance.Open("zipfile.zip");
To access the instance of ZipArchive (held inside the ZipHolder)
public void ShowImage(int theNum)
{
AbstractFile imageFile = ZipHolder.Instance.Zip.GetFile(zipFiles[num]);
if (imageFile.Exists)
{
using( Stream stImage = imageFile.OpenRead() )
{
pbMain.Image = Image.FromStream(stImage);
}
}
}
etc..
Gary
|
|
|
|
|
! Ahh worked like a charm! Took me a little modding (had to throw in a static, and change string to abstractfile) but sure enough, it works I can't thank you enough. Thanks ^^
|
|
|
|
|
I write these every day and still forgot the static in the example
Gary
|
|
|
|
|
Can anybody please help? Developed code WinXP SP2, works as expected when built as Debug or Release. Distribute to WinME partition - if 'filename' exists works, if it doesn't the new file is written to C:\windows\temporary internet files\ . Doesn't seem quite right! Significant Code (condensed!) is: -
// filename is path\newbak.cfg
string oldfile = filename;
oldfile = oldfile.Replace(".cfg",".old");
if (File.Exists(oldfile)) File.Delete(oldfile);
if (File.Exists(filename)) File.Move(filename,oldfile);
FileStream stream = new FileStream(filename, FileMode.OpenOrCreate, FileAccess.Write);
StreamWriter swr = new StreamWriter(stream);
swr.WriteLine(this.Title); // etcetera........
swr.Close();
stream.Close();
66 year young - or old and past it whichever! c# newbie.
|
|
|
|
|
What is the working directory of the application? I.e., is this an executable that is deployed using touchless deployment (launched from a browser)? By default, the application - like every other file you view in a browser - is downloaded to the temp. Internet files folder and executed. The working directory would be that directory unless you override it.
Also, a better way to deal with writing to streams is using the using block. This ensures that even if an exception occurs, the file handle (the native handle) is closed and you don't run into problems. Like so:
using (FileStream stream = new FileStream(filename, FileMode.OpenOrCreate, FileAccess.Write))
{
using (StreamWriter swr = new StreamWriter(stream))
{
swr.WriteLine(this.Title);
swr.Flush();
}
} This will dispose of the stream, which also closes the file handle. I don't remember if it is flushed in Dispose or not, but it doesn't hurt to call Flush anyway to make sure your writes are committed and not droped before the file handle is closed (loss of data).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|