|
Hi everyone,
I'm writing a C# forms application to open an existing Excel workbook using the Excel Interop. Everything works fine. I can read and write fine. I do not save the workbook until the user close the C# application. The problem happens when my program is running and the user accidentally opens the same workbook with Excel. I get the error:
Exception from HRESULT: 0x800401A8
at this line
Range excelRange = worksheet.UsedRange;
Is there a way to lock the workbook and not allow the user to open it with Excel when my program is running?
Thanks
|
|
|
|
|
please any one can tell me when we need to generate event using delegates and please send me code of event handling using delegates.
thanks in advance
|
|
|
|
|
See here..., It may Help You..,
Delegates & Events [^]
Rajesh B --> A Poor Workman Blames His Tools <--
|
|
|
|
|
|
A lots of resource on the internet. Why don't you try to search at google first.
Thanks
Md. Marufuzzaman
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
i want to know site where i can download msdn for visual studio.
hi
My english is a little.
anyway, nice to meet you~~
and give me your advice anytime~
|
|
|
|
|
This was answered yesterday[^]
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
|
Hello Friends,
I want to search a folder which is shared to "EveryOne", with its FileSyatemRigths.
I have a code:
ManagementObjectSearcher searcher = new ManagementObjectSearcher("select * from win32_share");
foreach (ManagementObject share in searcher.Get())
{
string path = share["Path"].ToString();
DirectoryInfo di = new DirectoryInfo(path);
DirectorySecurity ds = di.GetAccessControl();
DirectorySecurity myDirectorySecurity = di.GetAccessControl();
AuthorizationRuleCollection arc = myDirectorySecurity.GetAccessRules(true,true,typeof(System.Security.Principal.NTAccount));
myDirectorySecurity.RemoveAccessRule(new FileSystemAccessRule("EveryOne", FileSystemRights.FullControl , AccessControlType.Allow));
}
It gives me the all shared folder and tried to remove Sharing permission.
But it fails
i)if Sharing is not given to EveryOne
ii) If sharing is given to EveryOne but other than full control.
"Please suggest a way to retrive sharing folder having access given to Every one and then how to remove that access irrespective of Access
Permisssion"
Thanks in advance
|
|
|
|
|
Try this link.[^]
I hope this might be helpful to you.
Thanks
Md. Marufuzzaman
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
I've created a window service. In the OnStart() event a process is started to invoke a console application. Now in the OnStop() ctrl c need to be passed to the previously opened process (console app). Please let me know the way to do it.
"Don't worry if it doesn't work right. If everything did, you'd be out of a job." (Mosher's Law of Software Engineering)
|
|
|
|
|
|
If your service spawned the process, you can also kill that process. I believe it's Process.Stop() that you're interested in.
.45 ACP - because shooting twice is just silly ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "The staggering layers of obscenity in your statement make it a work of art on so many levels." - J. Jystad, 2001
|
|
|
|
|
Hello, I'm programming an C# application, one of the tasks I need to acomplish is to get a list of all the different combinations for a string. But not just all the combinations just the variations with some substrings, let me give an example so it can be more understandable:
STRING:
A1[8B]XY[TL]
The variables are the substrings that are withing [], so for the last string the right list of combinations would be:
A18XYT
A18XYL
A1BXYT
A1BXYL
In order to get the total number of combinations we just need to multiply all the substring's length, in this case:
[8B] length 2
[TL] length 2
2x2=4
The final list will have 4 strings, that is 4 different combinations.
The problem is that I cannot identify the way to fill the list so I do not get repeated strings.
Any hint/clue/help will be very appreciated.
I'm programming in C# but ANY pseudocode or other languages algorithms will be very welcome.
|
|
|
|
|
Hi,
1.
that is one of those rare problems that is handled well by using recursion. Basically you need to implement a single method that appends in turn each conceivable fraction of a combination to what you already have, then calls itself for the remainder of the job description.
Example: assuming you already have "A1" call yourself with argument "[8B]XY[TL]"; getting "[8B]" now, you foreach the possibilities, adding them to the result string, calling yourself again with "XY[TL]"
You could simply output the results or add them to a collection.
One advantage of recursion is you will get all possibilities in a nice predictable order.
2.
there is an alternate tactic provided the number of combinations is representable as an integer number.
It goes like this:
a. assume the variable substrings have P1, P2, ... Pp length
a. calculate the number of combinations N, i.e. the product of P1*P2*...*Pp as you stated;
b. loop an integer J from 0 to N-1
c. divide J by P1, use the remainder as the index in the leftmost possibilities string
d. divide the quotient by P2, use the remainder again as an index in the second possibilities string
etc.
The advantage here is all combinations are ordered again (different from the first method though), and you can simply calculate the K-th combination without calculating all the preceeding ones first.
|
|
|
|
|
With so few, I'd just define a struct with two character fields and make a list:
public struct Junk
{
public readonly char First ;
public readonly char Second ;
public Junk
(
char First
,
char Second
)
{
this.First = First ;
this.Second = Second ;
return ;
}
}
System.Collections.Generic.List<Junk> l =
new System.Collections.Generic.List<Junk>() ;
l.Add ( new Junk ( '8' , 'T' ) ) ;
l.Add ( new Junk ( '8' , 'L' ) ) ;
l.Add ( new Junk ( 'B' , 'T' ) ) ;
l.Add ( new Junk ( 'B' , 'L' ) ) ;
foreach ( Junk j in l )
{
System.Console.WriteLine ( "A1{0}XY{1}" , j.First , j.Second ) ;
}
Unless this is a homework assignment...
For a more general solution, I'd use my Combination extension method.
|
|
|
|
|
Hi, thanks for your response.
I'm actually looking for an absolute algorithm. A method that can be used with any string, not just with one or two specific ones.
|
|
|
|
|
Well, then I'd use loops to fill the List. No need to keep producing the same combinations over and over again.
System.Collections.Generic.List<Junk> l =
new System.Collections.Generic.List<Junk>() ;
foreach ( char f in new char[] { '8' , 'B' } )
{
foreach ( char s in new char[] { 'T' , 'L' } )
{
l.Add ( new Junk ( f , s ) ) ;
}
}
foreach ( Junk j in l )
{
System.Console.WriteLine ( "A1{0}XY{1}" , j.First , j.Second ) ;
}
This could be made more general.
Maybe I should read Luc's a little closer to see what it's doing.
|
|
|
|
|
FWIW: if you try method 2 and get bad results, I would guess you are doing something wrong. I just know it works well!
|
|
|
|
|
Actually I went for option #2 (long time since I have not work with recursion! even when I used to master a recursive programing language called Scheme!)
Anyways, did option #2 and It worked excellent, now I can submit any string into this method and it works great!
Thanks for sharing your light!
Regards.
|
|
|
|
|
you're welcome.
BTW: method 1 is actually simpler than method 2 provided you want all combinations.
|
|
|
|
|
Here's a generic version of a "one from column A, one from column B" algorithm.
Any number of columns should work and they don't need to all have the same number of items.
Empty columns are ignored (not tested).
public static System.Collections.Generic.IList<System.Collections.Generic.IList<T>>
MakeCombinations<T>
(
params System.Collections.Generic.IEnumerable<T>[] Values
)
{
System.Collections.Generic.List<System.Collections.Generic.IList<T>> result =
new System.Collections.Generic.List<System.Collections.Generic.IList<T>>() ;
if ( Values != null )
{
result.Add ( new System.Collections.Generic.List<T>().AsReadOnly() ) ;
for ( int i = Values.Length - 1 ; i >= 0 ; i-- )
{
if ( Values [ i ] != null )
{
System.Collections.Generic.List<System.Collections.Generic.IList<T>> temp =
new System.Collections.Generic.List<System.Collections.Generic.IList<T>>() ;
foreach ( T t in Values [ i ] )
{
foreach ( System.Collections.Generic.IList<T> many in result )
{
System.Collections.Generic.List<T> one =
new System.Collections.Generic.List<T>() ;
one.Add ( t ) ;
one.AddRange ( many ) ;
temp.Add ( one.AsReadOnly() ) ;
}
}
if ( temp.Count > 0 )
{
result = temp ;
}
}
}
}
return ( result.AsReadOnly() ) ;
}
System.Collections.Generic.IList<System.Collections.Generic.IList<string>> c =
MakeCombinations
(
new string[] { "Blonde" , "Brunette" , "Redhead" , "Black" }
,
new string[] { "Blue" , "Brown" , "Green" }
,
new string[] { "A" , "B" , "C" , "D" , "DD" , "DDD" }
) ;
Now I need to get to bed...
|
|
|
|
|
I'm building kiosk software where we need to be able to display a PDF file. Because this is a kiosk, there is no user interaction which means that it is filled with issues. What do you do with multiple pages, we are displaying on a plasma so the aspect ratio is wrong which means there will be black bars, we'd like to not have any menus since they take up real estate.
So does anybody have any ideas? One we came up with was to convert the document to jpgs, one page per image, and then scroll through them. This works but the library I looked at (http://www.aspose.com/) is slow (about 2 seconds a page).
I've also looked at the Adobe ActiveX control (just started looking at it) but we've had issues before where Adobe wants to update itself and puts a message on the screen.
So does anybody have any suggestions/thoughts on this?
TIA - Jeff.
|
|
|
|
|
Just a thought...
jbradshaw wrote: One we came up with was to convert the document to jpgs, one page per image, and then scroll through them. This works but the library I looked at (http://www.aspose.com/) is slow (about 2 seconds a page).
Is the PDF generated dynamically by software you don't control? Can you just create the JPEG's in advance (once, when you write the software), then display those and not have to worry about PDF's? And why does speed matter that much? Can't you just convert the PDF in advance (i.e., right before it's needed), then you'll have each page as a JPEG to scroll as you please? Also, any reason you chose JPEG? Do your PDF's contain natural type images (e.g., photography), or does it contain just text? If just text, PNG may be a more ideal format (lossless and compresses very well with computer generated images).
I did some Googling and came across ImageMagick, which apparently converts images and supports PDF as an input format (note that, for PDF's, it says it requires Ghostscript).
|
|
|
|
|
If Aspose is too slow, here's another library you might want to try: GDPicture.NET[^]
I haven't used it in any projects yet, but I did try it for a proof-of-concept to create a pdf from a composite image. It wasn't too hard to use and got the job done.
|
|
|
|