|
The easiest way is File.WriteAllText. However, there's file modes you can use to specify if you are appending or creating. I just suspect that FileStream does not offer them.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thanks a lot!
I used File.WriteAllText though, works fine. Now I'll just have to adjust my application for it.
/Joplinazz
|
|
|
|
|
Any there any free (or < $100) obfuscators that will obfuscate mixed mode assemblies?
Dotfuscator free edition will not. Skater Lite will not and I don't think that the Skater Pro version will either.
|
|
|
|
|
I doubt you can obfuscate mixed mode assemblies.
|
|
|
|
|
I think that the Professional version of Dotfuscator will handle mixed mode assemblies but I think that this version is expensive $$$ (much more than $100).
|
|
|
|
|
Sorry I cant help then
|
|
|
|
|
Hello all
I have a simple form and a picturebox control on it
when I loaded an image(PNG file) by the image property and then
I ran the program
I got a grey-colored picture with the same boundaries of my actual
colored picture.
I tried to change the picture to other pictures (also png) they worked correctly, so the result is, some pictures are viewed correctly and some
are not.
any help?
|
|
|
|
|
The picture changes to greyscale ? your code has to be doing that, no way does it happen on it's own.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi, thanks for replying
but I know grey-scaled images and that picture
is not.
that picture has no scaling at all, it is just grey.
note: I loaded bmp pics and all is OK.
|
|
|
|
|
OK - I misunderstood. Can Paint open the image ? it seems GDI+ cannot.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Yes, Paint and all imaging programs can open it clearly.
you think? I tried the sample on 3 PCs and the result is totally the same.
so should I use JPG instead?
It's a near-to-end commercial application.
|
|
|
|
|
Well, I guess so. That's really odd, but for whatever reason, the built in stuff is obviously having trouble.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Ok, Thanks
I think I'm done
|
|
|
|
|
Hi,
I have a COM object that actually allocate a memory and return a value to the calling function. When I call this COM object in C++, I can just delete the pointer by using delete keyword. But how can I do this in C#? How to free the memory allocated by the COM object?
eg.
In my COM class:
HRESULT __stdcall CTestCOM::getValues(int **arrRetVal)
{
int *pTmp = new int[100];
...
...
...
(*arrRetVal) = pTmp;
return S_OK;
}
Thanks
|
|
|
|
|
Btw, I tried to use both Marshal.FreeCoTaskMem() and Marshal.FreeHGlobal() but it crashes with error:
Invalid Address specified to RtlFreeHeap( 00210000, 055AB388 )
Cheers
|
|
|
|
|
Why not add a method to the COM class that deletes a pointer that it is provided in a parameter? (Assuming here that .NET doesn't do something nasty to the pointer that makes this impossible/wrong, I'm no expert on COM Interop...)
|
|
|
|
|
Hi Trichards57,
Every good idea. I can pass in the pointer it returns to C# and pass it back to the COM object to delete it.
I have to test it first though.
Thanks for your help
Cheers
|
|
|
|
|
Hello every body, I need to know how could I proceed to comunicate my PC by the rs232 port(serial port) with a ligthing table wich have DMX control. I mean, I need to know what is the format I have to use to comunicate my PC whit this table via rs232 and manipulate all ligths.
I know that the insert port wich table have is a rs485 protocol, but if I can send my string from my PC to the table, what format I have to use??
What is the format of the RS485 protocol.
Please, if some body knows what I have to do, I will very gratefull...
Hola a todos, necesito saber como debo proceder para comunicar mi PC con una consola de luces, se que la consola tiene como protocolo el DMX y que el puerto de entrada es el rs485, pero si yo pongo un adaptador de señales desde mi puerto se serie (rs232) culal deberia ser el formato que deberia tener en cuenta para mover las luces que controla la consola?
Es decir, cual es el protocolo que deberia usar para poder manipular dichas luces desde mi pc??
Por favor, si alguien psabe como hacerlo, les estare muy agadecido...
|
|
|
|
|
|
The DMX software protocol is described here:
http://www.theater-technisch-lab.nl/dmxen.htm
RS-485 is not actually a protocol but a hardware interface.
It transmits data as the voltage difference between two data lines, rather than the absolute voltage on a single data line. Software wise, it is exactly like RS-232 but its maximum cable length is much further (roughly 1000M vs 12M).
In other words, for DMX you cannot use your serial port, have to spend money on hardware. The cheapest I have found is the Enttec Open DMX controller. (USD) $60.
If you are writing your own code this guy, Hippy, is a great start.
http://members.westnet.com.au/rowanmac/opendmx.html
He has an open source VB that shows how to write to the controller.
One thing to watch out for is installing the driver for the controller.
The included driver did not work for me on WinXP.
But the following did:
http://www.enttec.com/dmx_usb/d2xx_setup.exe
Here is a quick and dirty C# class to run the Enttec OpenDmx usb controller:
using System;
using System.Runtime.InteropServices;
using System.IO;
using System.Threading;
namespace Test
{
public class OpenDMX
{
public static byte[] buffer;
public static uint handle;
public static bool done = false;
public static int bytesWritten = 0;
public static FT_STATUS status;
public const byte BITS_8 = 8;
public const byte STOP_BITS_2 = 2;
public const byte PARITY_NONE = 0;
public const UInt16 FLOW_NONE = 0;
public const byte PURGE_RX = 1;
public const byte PURGE_TX = 2;
[DllImport("FTD2XX.dll")]
public static extern FT_STATUS FT_Open(UInt32 uiPort, ref uint ftHandle);
[DllImport("FTD2XX.dll")]
public static extern FT_STATUS FT_Close(uint ftHandle);
[DllImport("FTD2XX.dll")]
public static extern FT_STATUS FT_Read(uint ftHandle, IntPtr lpBuffer, UInt32 dwBytesToRead, ref UInt32 lpdwBytesReturned);
[DllImport("FTD2XX.dll")]
public static extern FT_STATUS FT_Write(uint ftHandle, IntPtr lpBuffer, UInt32 dwBytesToRead, ref UInt32 lpdwBytesWritten);
[DllImport("FTD2XX.dll")]
public static extern FT_STATUS FT_SetDataCharacteristics(uint ftHandle, byte uWordLength, byte uStopBits, byte uParity);
[DllImport("FTD2XX.dll")]
public static extern FT_STATUS FT_SetFlowControl(uint ftHandle, char usFlowControl, byte uXon, byte uXoff);
[DllImport("FTD2XX.dll")]
public static extern FT_STATUS FT_GetModemStatus(uint ftHandle, ref UInt32 lpdwModemStatus);
[DllImport("FTD2XX.dll")]
public static extern FT_STATUS FT_Purge(uint ftHandle, UInt32 dwMask);
[DllImport("FTD2XX.dll")]
public static extern FT_STATUS FT_SetBreakOn(uint ftHandle);
[DllImport("FTD2XX.dll")]
public static extern FT_STATUS FT_SetBreakOff(uint ftHandle);
[DllImport("FTD2XX.dll")]
public static extern FT_STATUS FT_GetStatus(uint ftHandle, ref UInt32 lpdwAmountInRxQueue, ref UInt32 lpdwAmountInTxQueue, ref UInt32 lpdwEventStatus);
[DllImport("FTD2XX.dll")]
public static extern FT_STATUS FT_ResetDevice(uint ftHandle);
[DllImport("FTD2XX.dll")]
public static extern FT_STATUS FT_SetDivisor(uint ftHandle, char usDivisor);
[DllImport("FTD2XX.dll")]
public static extern FT_STATUS FT_ClrRts(uint ftHandle);
public static void start()
{
buffer = new byte[4]; // can be any length up to 512. The shorter the faster.
handle = 0;
status = FT_Open(0, ref handle);
Thread thread = new Thread(new ThreadStart(writeData));
thread.Start();
setDmxValue(1, 0); // set DMX channel 1 to maximum value
}
public static void setDmxValue(int channel, byte value)
{
buffer[channel]=value;
}
public static void writeData()
{
while (!done)
{
initOpenDMX();
FT_SetBreakOn(handle);
FT_SetBreakOff(handle);
bytesWritten = write(handle, buffer, buffer.Length);
System.Threading.Thread.Sleep(50);
}
}
public static int write(uint handle, byte[] data, int length)
{
IntPtr ptr = Marshal.AllocHGlobal((int)length);
Marshal.Copy(data, 0, ptr, (int)length);
uint bytesWritten = 0;
FT_Write(handle, ptr, (uint)length, ref bytesWritten);
return (int)bytesWritten;
}
public static void initOpenDMX()
{
status = FT_ResetDevice(handle);
status = FT_SetDivisor(handle, (char)12); // set baud rate
status = FT_SetDataCharacteristics(handle, BITS_8, STOP_BITS_2, PARITY_NONE);
status = FT_SetFlowControl(handle, (char)FLOW_NONE, 0, 0);
status = FT_ClrRts(handle);
status = FT_Purge(handle, PURGE_TX);
status = FT_Purge(handle, PURGE_RX);
}
}
public enum FT_STATUS2
{
FT_OK = 0,
FT_INVALID_HANDLE,
FT_DEVICE_NOT_FOUND,
FT_DEVICE_NOT_OPENED,
FT_IO_ERROR,
FT_INSUFFICIENT_RESOURCES,
FT_INVALID_PARAMETER,
FT_INVALID_BAUD_RATE,
FT_DEVICE_NOT_OPENED_FOR_ERASE,
FT_DEVICE_NOT_OPENED_FOR_WRITE,
FT_FAILED_TO_WRITE_DEVICE,
FT_EEPROM_READ_FAILED,
FT_EEPROM_WRITE_FAILED,
FT_EEPROM_ERASE_FAILED,
FT_EEPROM_NOT_PRESENT,
FT_EEPROM_NOT_PROGRAMMED,
FT_INVALID_ARGS,
FT_OTHER_ERROR
};
}
modified on Thursday, September 24, 2009 6:54 PM
|
|
|
|
|
hi every body
the idea of my project in general is to read an excel file and save them to to DB.
so I put a progress bar that work while reading the excel file but the problem is that the progress bar seems hung and doesn't work while reading.
I didn't find any solution for that so please I need ur help
thank u....
|
|
|
|
|
Genius.Boy,
You need to do the reading of the excel file in another thread. BackgroundWorker would be best to use, as it allows for you to also update the progress bar.
MSDN[^]
Regards,
Gareth.
(FKA gareth111)
|
|
|
|
|
Thank u Mr. Gareth H
Nice solution...
.
.
thank u again
Genius.Boy
|
|
|
|
|
i made a error reporter and i want to display a "Debug" button on my form...
I want to only show this button if theirs a debugger installed...
basically i want to display the Just-In-Time debugger window.
Anyway to do this?
|
|
|
|
|
There is a precompiler option #if DEBUG that could work for you. Otherwise a series of if-statements is the only choice.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|