|
As you want to alter the default behaviour of a folder, thats going to be very tricky.
One possible hackaround could be, create a new file extension and alter the behaviours. That way you could have a default action of 'open program', but also had a secondary action to open a folder.
The only other possible thought would be to see how you can create those 'special' windows folders (control panel, .net assembly etc) if you could work that out...but that would be a nightmare of registry hacks, and not something I would like to see a program 'do' if I was a user.
|
|
|
|
|
I agree it is not something I would normally be wanting to do but it is being required of me to find a solution like this. It sort of works like the mac application package folder from the research of what their requesting of me.
|
|
|
|
|
Does anyone know how to access a media player playlist and its songs without having to instantiate the AxWindowsMediaPlayer?
[EDIT] I am aware of the wpl location and parse the xml, but doesnt help with the auto playlists.
modified on Tuesday, September 1, 2009 5:19 PM
|
|
|
|
|
Ok, silly question...excuse me while I try to understand exactly how the stack works:
Example:
int a = 123;
int b = 456;
int c = b;
If the stack was horizontal, with first in on the right, you have: c = 456 | b = 456 | a = 123
Now set:
b = 789;
You have: c = 456 | b = 789 | a = 123
Ok, fine, no problem...but how did b get changed if you have to 'pop' c off to get to b?
|
|
|
|
|
Locals in C# do not get on the stack in the MSIL phase. They will, of course, after the JIT compiler has done its job, but that's a different kind of stack.
Both are easy to check:
- for the MSIL way, open the assembly (in the meaning of ".NET assembly" which is a file) with the Reflector and set it to IL view
- for the native way, put a breakpoint somewhere and debug, when you hit the breakpoint open the disassembly window
|
|
|
|
|
Some more info:
For locals, MSIL has stloc and ldloc in various forms, they operate on "local slots" (and the stack of course, to get their operands from, but they don't put their data there)
(talking to myself, yay)
|
|
|
|
|
I'm assuming by stack you mean the stack that the program stores it's local variables in (not one you've produced yourself using the Stack class.
When the variables are stored, the stack is just a way of looking at the specific area of memory. Unlike the .Net Stack class, you don't have to pop things off to access them. The same region of memory could also be treated as a list, a queue, or anything else. The program stores the address of each variable, and then accesses them directly, so you can access b without touching c . Then, when the function finishes, all the variables are popped off of the stack.
This is one of several ways of storing local variables in a function, and is very low level stuff. You shouldn't have to worry too much about it.
Disclaimer: The .Net Framework may do something different to the stack, but the principle should be the same.
|
|
|
|
|
Thanks for the replies, yes I was talking about local variables, and not the Stack class. Yes, I agree that I don't want to worry too much about low-level memory management.
The confusion came about because of all the images on the internet that show the stack as a bunch of boxes on top of each other. Someone asked me that question, and I suddenly realized I couldn't give them an answer!
Thanks again,
--Alex
|
|
|
|
|
Hi,
the stack is a region in memory pointed to by a special register, the stack pointer.
It is special in the sense that some assembly instructions implicitly use the stack pointer:
CALL/JSR push the current PC on the stack
RETURN/RTS pop the old PC value from stack and store it in the PC register
PUSH pops anything onto the stack
POP pops anything from the stack
On top of that, the stack pointer can be used as a regular base register, so indexed addressing is supported. Local variables, while stored on the stack are accessed with an offset (or "displacement") so there is no pushing/popping involved.
Summary: the stack works as a regular stack (implied pushes and pops) when program flow alters (CALL, RETURN); it is used as a memory region (with base address+offset) when local variables are accessed.
All the above is valid at two different levels:
- assembly instructions (as in native code applications);
- .NET environment with IL instructions (managed code).
|
|
|
|
|
I'm having a problem in sorting strings. All the strings are saved in a text file. Now i retrieved the strings from the text file and transferred it into an array. I'll be using radix sort to sort the strings because I think its the most appropriate algorithm to use beside any other sorting algorithm. But first I want to convert all the strings into their corresponding ASCII codes and store all the ASCII codes into a temporary array so I can sort them in a much better way.
Now my problem is always get the FormatException during run-time. How will I solve that error? I already declared an array that's an int type but i still get that error.
using (StreamReader outputLastNames = new StreamReader("lastnames.txt"))
{
for (int i = 0; i < vehicleCountInt; i++)
{
arrayOfLastNames[i] = outputLastNames.ReadLine();
convertedLastName[i] = Int32.Parse(arrayOfLastNames[i]);
}
}
important notes:
convertedLastName[i] is an int[] type
arrayOfLastNames[i] is a string[] type
modified on Tuesday, September 1, 2009 2:42 PM
|
|
|
|
|
OK, I don't get why you want to convert to ASCII, but never mind. What do you get the FormatException on? If you don't show us the code that gives the problem, it is next to impossible to help. Don't paste the lot, just the relevant fragment, and don't forget to enclose it in <pre></pre> markers to preserve the formatting (makes it easier for us to read).
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
How do expect to parse a (person's?) name to an int?
If your last name is 1127 it would work; but not with most names.
|
|
|
|
|
Just a guess, but are you sure all of the characters in the name can be converted to int?
only two letters away from being an asset
|
|
|
|
|
How can a character in a name be converted to an int?
Anyway - this will handle it using the TryParse method, though I suspect you're going to spend most of your time in the else block.
int converted;
if(Int32.TryParse(arrayOfLastNames[i], out converted)
{
convertedLastName[i] = converted;
}
else
{
}
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Int32.Parse would work with char and not strings. i.e. (char)'A' will be converted to its ASCII equivalent but (string)"A" will not. You will need to get each character of the last name and then convert.
AFAIK .Net uses UTF8 encoding to store strings, probably that is the reason it is not working now.
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
Uggh...What was I thinking?! My fault guys..wrong question..I was thinking about the type of an ASCII code.
So, is there a way to convert all the string into an ASCII code? I was thinking of converting all of the string to ASCII code because I think it's a good way to do to sort using radix sort just like what i said above.
modified on Tuesday, September 1, 2009 3:40 PM
|
|
|
|
|
1. Why can't you use Array.Sort method?
2. AFAIK the number of recursions depend upon the maximum number digits in the numbers. Hence, if you have last names like MacGhilleseatheanaich[^], I wonder how many iterations it would take.
To convert string to ASCII equivalent, you can use following code:
System.Text.Encoding encASCII= System.Text.Encoding.ASCII;
Byte[] stringBytes = encASCII.GetBytes(yourString);
It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD
|
|
|
|
|
The reason why i can't use Array.Sort() is because we're trying to implement all that we discussed about file organization and data structure etc, and because we discussed some sorting algorithms we'll be implementing radix sort. If we were not obliged to use radix sort, I would be eager to use Array.Sort and finish the program easily.
|
|
|
|
|
They're already in ASCII.
But if you want to waste bits by using int (32 bits) rather that char (16 bit), you can cast the chars to ints.
foreach ( char ch in s )
{
int i = (int) ch ;
...
}
|
|
|
|
|
Hi Everyone,
I have a "one to many" sort of situation. I am using a Key to get subset data. I started out using a class like this:
<code>
public class Contract
{
public int ContractID {get;set;}
public int CustomerID {get;set;}
public string CustomerName {get;set;}
public string Organization {get;set;}
public int TermsID {get;}
}
public class ContractDataMapper
{
public static List<Contract> GetContractData(int contractID)
{
List<Contract> returnValue = new List<Contract>();
...
while(reader.Read())
{
Contract contract = new Contract();
contract.CustomerID = Convert.ToInt32(reader["CustomerID"]);
contract.CustomerName = reader["CustomerName"].ToString();
...
if(!returnValue.Contains(contract))
returnValue.Add(contract);
}
reader.Close();
command.Dispose();
return returnValue();
}
}
</code>
But I soon realized that this is bad because I had to check to see if this ContractID has any TermsID associated with it and the way it currently is I would have to do something like:
if(ContractDataMapper.GetContractData(1234)[0].TermsID > 0)
Ideally I should have one class Contract and have other properties in a subclass. Now my question is ... do you think it would be better to have a struct or a subclass or something else?
Contract contract = new Contract(1234);
List<SubsetData> subset = contract.SubsetData;
I would appreciate your help.
|
|
|
|
|
|
using Automation (SHDocVw, MSHTML or something else?) or a WebBrowser control:
1)Is it possible to interrogate a flash control to discover its elements? For example, http://demo.garanti.com.tr/bireysel_demo/main.html[^], there are flash buttons. Can I determine there "ID"s?
2)Given the "ID" names of elements in a flash control, is it possible to click and/or select them?
|
|
|
|
|
New to C# - long time cobol programmer....
How do you define a db connection so it can be used across several windows forms?
I have the connection working but I have to establish the connection in each form.
iDB2Connection cn = new iDB2Connection();
cn.ConnectionString = "DataSource=" + txtiSeries.Text.Trim(' ')
+ ";DefaultCollection=" + txtDataLibrary.Text.Trim(' ')
+ "; UserID=" + txtUserId.Text.Trim(' ')
+ "; Password=" + txtPwd.Text.Trim(' ') + ";LibraryList=*USRLIBL;";
try
{
cn.Open();
}
catch (iDB2CommErrorException x)
I would like to be able to establish the connection 1 time when the application starts and then be able to use it
across all of the windows forms.
Just not sure were or how to define it.
Any help would be appreciated.
Thanks
|
|
|
|
|
It would be a bad idea to keep the database connection open constantly, It is much better to create a connection each time you need one.
I tend to use a class that does all my database work, which includes creating a connection when needed. This class provides functions for specifying search criteria. You could consider a simple class that simply takes an SQL query string and returns a datatable of the results (for search functionality) - In this case database connection string could be a static member of the class which is set when the application first loads.
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Create a data class that handles all data calls to & from the data source. I have one if you need it.
Then in your main class, mine is called csApp, create a class variable that holds it:
public static DataClass DataAccess;
Next, in the Main method do:
public static void Main(String[] args)
{
DataAccess = new DataClass();
}
Then, anytime you need to call into the data source you can do:
DataSet ds = csApp.DataAccess.GetDataSet("select * from ....")
This way it's always available. And you should always close the connection when you're
not using it.
Everything makes sense in someone's mind
|
|
|
|