|
Assume chars2 holds N letters, and chars1 holds at least N.
Now try some index i and check that for all values j in [0,N-1] chars1[i+j] equals chars2[j]; if so, you have a match at position i.
Hence, two nested for loops would be sufficient; it may not be the most efficient way, it is an effective one.
|
|
|
|
|
|
Right. Of course.
But actually, there is no need to explicitly create the char arrays, as a string is perfectly indexable as is: string[i] returns the i-th character all by itself (as it did in C).
|
|
|
|
|
Hi All,
I'm recieving a System.IO.Exception after creating a file and then trying to append text to that file. The message I recieve is:
The process cannot access the file 'File path goes here' because it is being used by another process.
The code to create the file is:
if (!File.Exists(filePath))
File.Create(filePath);
The code I'm using to try and append text to the file is:
StreamWriter sw = File.AppendText(readIDFilePath);
Does any one have any clue to why I am recieving this exception? Does File.Create open the file it's creating?
Is the file already exists then no System.IO.Exception is recieved.
Any feedback would be greatly appreciated.
Thanks,
Mel
|
|
|
|
|
According to the documentation[^], File.Create returns a FileStream that provides read/write access to the file specified in path.
So in answer to your question, yes File.Create does open the file.
Use the returned FileStream to write your data, or call dispose on the filestream before using AppendText.
|
|
|
|
|
Thanks for your feedback, I captured the FileStream that File.Create returns and close/disposed it as you suggested and it works great.
I guess I was just looking at it for too long and over looked the obvious.
Thanks again.
Mel
|
|
|
|
|
You should be able to figure this one out yourself, mainly by reading the documentation on the classes and methods you use.
I would agree with you if you were to say the error message you are getting isn't perfect; when it says "... by another process" that may include your very own process too, so "another process" should really be "some (maybe this) process".
|
|
|
|
|
this file may be opened last time and not be closed.
|
|
|
|
|
right now I have one column header that does not alphabetically sort its self when column header is clicked.
so I figured I can make an event if that column header is clicked to a column header that sorts the it how I need to
Column header Im targeting is gridView.columnFlags
so far I have
private void OnColumnHeaderClick(object sender, Divelements.SandGrid.GridColumnEventArgs e)
{
if (e.GridColumn.Equals(columnTest))
{
}
gms.HandleSort(e.GridColumn);
|
|
|
|
|
As this is a 3rd party control, you are more likely to get help if you ask on their web site. Here[^].
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
Why do programmers often confuse Halloween and Christmas? - Because 31 Oct = 25 Dec.
Business Myths of the Geek #4 'What you think matters.'
|
|
|
|
|
Hello,
I'm using C# in Visual Studio 2008. Is it possible to trap the F1 key in a file dialog (Open or 'Save As')? I've been searching on the internet for the answer to this but I've found none. Any help is appreciated.
Regards,
Mike
|
|
|
|
|
Although I have never done this, my first thought is GetActiveWindow + Global keyboard hook.
|
|
|
|
|
d@nish,
I'm not sure about the GetActiveWindow, but I found a global keyboard hook program. Everything appears to be working now. Thank you for your help.
Regards,
Mike
|
|
|
|
|
Really? You might want to see what happens in your app while its running and the user switches to another app and hits F1.
|
|
|
|
|
Dave,
What happened when you did this?
Regards,
Mike
-- Modified Tuesday, June 15, 2010 11:45 AM
|
|
|
|
|
Remember, that's a GLOBAL keyboard hook, that means SYSTEM GLOBAL, not application. If the users hits that key, while your app is running, in ANY application or Explorer window, it'll fire in your application. Is that what you want it to do??
|
|
|
|
|
It is "global keyboard hook". That will work regardless of the active window. So, if you have a notepad and your application running, and user presses F1 in the notepad, still the code in your application will fire. That is why I said GetActiveWindow + global keyboard hook.
You should check in which window is that F1 key pressed and then process it.
|
|
|
|
|
Hello,
Creating one calendar folder (..\<account>\Calendar\<folder>) works without problems. (Using a MKCOL Query for IPF.Appointment).
However creating a sub-sub folder (needed for example dept/responsable/employee) it keeps giving me a "409 Conflict" Error from exchange. Creating the folder manually in outlook works fine.
Code is the following.
string sUri = "http://ExchServer/Exchange/vonb/calendar/xxx";
System.Uri myUri = new System.Uri(sUri);
HttpWebRequest HttpWRequest = (HttpWebRequest)WebRequest.Create(myUri);
string sQuery;
sQuery = "<?xml version='1.0'?>" +
"<a:propertyupdate xmlns:a='DAV:' " +
"xmlns:ex='http://schemas.microsoft.com/exchange/'>" +
"<a:set><a:prop>" +
"<ex:outlookfolderclass>IPF.Appointment</ex:outlookfolderclass>" +
"</a:prop></a:set>" +
"</a:propertyupdate>";
NetworkCredential myCred = new NetworkCredential(@"<myUser>", "<myPWD>");
CredentialCache myCredentialCache = new CredentialCache();
myCredentialCache.Add(myUri, "NTLM", myCred);
HttpWRequest.Credentials = myCredentialCache;
HttpWRequest.KeepAlive = false;
HttpWRequest.Headers.Set("Pragma", "no-cache");
HttpWRequest.ContentType = "text/xml";
HttpWRequest.ContentLength = sQuery.Length;
HttpWRequest.Timeout = 300000;
HttpWRequest.Method = "MKCOL";
byte[] ByteQuery = System.Text.Encoding.ASCII.GetBytes(sQuery);
HttpWRequest.ContentLength = ByteQuery.Length;
Stream QueryStream = HttpWRequest.GetRequestStream();
QueryStream.Write(ByteQuery,0,ByteQuery.Length);
QueryStream.Close();
HttpWebResponse HttpWResponse = (HttpWebResponse)HttpWRequest.GetResponse();
int iStatCode = (int)HttpWResponse.StatusCode;
Comes directly from MSDN, so should be fine
Any help would be apreciated, thanks
vonb
|
|
|
|
|
Hi,
I have a Win Form application (C# Net Framework 3.5) which I try to run on Windows 7. In my local network I set up an AD LDS role to a windows 2008 server. I make an application store by using azman on AD LDS. Define operations, task, roles and roles assignments on it. Using Enterprise Library 5.0 security application block I add an AzMan Authorization Provider to my app.config in Win Form. Here is the properties that I set;
Name: MyProvider
Application:
Application Scope:
Audit Identifier Prefix: W
Store Location: LDAP://WS2008:389/CN=STR2,CN=WS,DC=PW,DC=COM
Type: AzManAuthorizationProvider
In Win Form I code like this..
WindowsIdentity identity = WindowsIdentity.GetCurrent();
WindowsPrincipal principal = new WindowsPrincipal(identity);
IAuthorizationProvider iAuthorizationProvider = AuthorizationFactory.GetAuthorizationProvider();
bool auth = iAuthorizationProvider.Authorize(principal, "BackUpAdmin");
the last line gives the following error
Application attempted to perform an operation not allowed by the security policy. To grant this application the required permission, contact your system administrator, or use Microsoft .NET Framework Configuration tool.
I want to understand why .net apply security policy for the code. How could I grant the application for the required permission. Did it relevant only on Client part (Windows 7), did I do anything on Windows 2008 server.
I can reach application store via azman.msc on windows 7...
Please inform and advice me..
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.Security.SecurityException: The specified network provider name is invalid. (Exception from HRESULT: 0x800704B4) --->
karanba
modified on Tuesday, June 15, 2010 10:55 AM
|
|
|
|
|
Before anyone will help you you need to cut down on the code dump: just post the fragments that are pertinent to the issue and no more.
me, me, me
"The dinosaurs became extinct because they didn't have a space program. And if we become extinct because we don't have a space program, it'll serve us right!"
Larry Niven
nils illegitimus carborundum
|
|
|
|
|
How can i add some properties to Object. or String.
for example i wanna to add <<isnull>> to Object so I can call this property by <<object.isnull>> Or I wanna to add this to String ===> String.IsNull something like :
string.IsNullOrEmpty
object.Equals
Thanks
|
|
|
|
|
|
I want to add property directly to String. OR Object.
Not :
String name = "Ali";
bool IsNullString = name.IsNull();
But I wanna to have this :
String name="Ali";
bool IsNullString = String.IsNull(name);
Or
Object its own self has two properties (object.Equals , object.ReferenceEquals) how can i add IsNull to the object it self
so i can use that something like this :
object obj = "Ali";
bool IsNullObject = object.IsNull(obj);
modified on Tuesday, June 15, 2010 9:03 AM
|
|
|
|
|
why? you don't seem to read the answer anyway.
|
|
|
|
|
I have read the ans ! But I wanna to have this
I want to add property directly to String. OR Object.
Not :
<pre>String name = "Ali";
bool IsNullString = name.IsNull();</pre>
But I wanna to have this :
<pre>String name="Ali";
bool IsNullString = String.IsNull(name);</pre>
Or
Object its own self has two properties <code>(object.Equals , object.ReferenceEquals)</code> how can i add <code>IsNull</code> to the object it self
so i can use that something like this :
<pre>object obj = "Ali";
bool IsNullObject = object.IsNull(obj);</pre>
|
|
|
|