|
Yea, I ran into this problem too...this should help...save using the encoder...if it returns nothing...then you will need to use a default encoder...like for a bitmap or something.
Private Shared Function FindImageEncoder(ByVal theImg As Image) As ImageCodecInfo
For Each info As ImageCodecInfo In ImageCodecInfo.GetImageEncoders
If info.FormatID.Equals(theImg.RawFormat.Guid) Then Return info
Next info
Return Nothing
End Function
Apparently it's not OK to start a bonfire of Microsoft products in the aisles of CompUSA even though the Linuxrulz web site says so
|
|
|
|
|
Thanks a lot!
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
Any time, hope it helps, if not let me know.
Apparently it's not OK to start a bonfire of Microsoft products in the aisles of CompUSA even though the Linuxrulz web site says so
|
|
|
|
|
Dear Group,
Here's what my app is attempting:
1) rename a JPEG file temporarily
2) create a thumbnail for that JPEG
3) save the thumbnail in a separate folder
4) rename the JPEG file back to its original name
1), 2), and 3) work fine. 4) is where I have the problem. My program halts with this error:
"The process cannot access the file because it is being used by another process."
Here's the code:
' Step 1)
My.Computer.FileSystem.RenameFile("TestImage.jpg, _
"TestImage.jpg.working")
' Step 2)
Dim bmpSS As Bitmap
Dim intBW As Integer ' thumbnail width
Dim intBH As Integer ' thumbnail height
Dim bmp As Bitmap = New Bitmap("TestImage.jpg.working")
bmpSS = New Bitmap(250, CInt(bmp.Height / (bmp.Width / 250)), _
Imaging.PixelFormat.Format32bppArgb)
intBW = bmpSS.Width
intBH = bmpSS.Height
Dim g As Graphics = Graphics.FromImage(bmpSS)
g.DrawImage(Bmp, 0, 0, intBW, intBH)
' Step 3)
bmpSS.Save("C:\Temp\TestImage_250.jpg")
g = Nothing
bmp = Nothing
bmpSS = Nothing
' Step 4)
My.Computer.FileSystem.RenameFile("TestImage.jpg.working", _
"TestImage.jpg")
As I said, it all works until it hits step 4). Is there some locking issue that I'm missing here?
Regards,
Steve Erbach
Neenah, WI
http://TheTownCrank.blogspot.com
|
|
|
|
|
serbach wrote: Dim bmp As Bitmap = New Bitmap("TestImage.jpg.working")
You need to call Dispose on this object before you'll be able to rename or overwrite the file in question.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian,
» You need to call Dispose on this object before you'll be able to rename or overwrite the file in question. «
Thank you! That is precisely what I needed!
Sincerely,
Steve Erbach
Neenah, WI
http://TheTownCrank.blogspot.com
|
|
|
|
|
DataSet ds = TextToDataSet.Convert(
"c:\test.txt", "MyNewTable", "\t");
Rekha
|
|
|
|
|
It would look like this:
Dim ds as DataSet = TextToDataSet.Convert("c:\test.txt", "MyNewTable", "\t")
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
Actually, there's got to be an error in that C# code. Since the "c:\.." doesn't have the backslash escaped, the "\t" is a tab character.
Here's the VB equivalent via Instant VB, which shows the original problem more clearly:
Dim ds As DataSet = TextToDataSet.Convert("c:" & Constants.vbTab & "est.txt", "MyNewTable", Constants.vbTab)
David Anton
www.tangiblesoftwaresolutions.com
Instant C#: VB to C# converter
Instant VB: C# to VB converter
C++ to C# Converter: converts C++ to C#
Instant C++: converts C# to C++/CLI and VB to C++/CLI
Instant Python: converts C# to IronPython and VB to IronPython
|
|
|
|
|
DataSet ds = TextToDataSet.Convert(
"c:\test.txt", "MyNewTable", "\t");
Rekha
|
|
|
|
|
dim ds as dataset = TextToDataSet.Convert("c:\test.txt", "MyNewTable", "\t")
|
|
|
|
|
I would like to know if anyone knows a good source for windows installer conditions. I want to know how to set the condition so that when someone is installing the setup app knows whether the database is already installed and therefore does not copy over the exsisting data
|
|
|
|
|
|
what i need is a website that better explains and examples the syntax for the condition property. Everytime someone on here tells me that its not possible or i need to use this special thing or that i always find a way to do it and prove them wrong. thank you for the info on the custom installer though.
|
|
|
|
|
I am sorry that my answer did not help you totally. What I have noticed in building my latest application is that there are not a lot of resources for the Visual Studio - Windows Installer project. I do not think that many people use it for our of the ordinary installations. My guess is that most people use an InstallShield or Wise.
One site that I go to for installation information (other than Google) is http://www.installsite.org/.
|
|
|
|
|
Hey everyone,
I just figured out how to add custom toolbox controls and I was wondering if anyone had any favorites they'd like to share?
I've tried out XtraNavBar http://www.devexpress.com and also a couple free ones that came with VB 2005 express. I'd like to find some more, now that I know how to use them.
I'd like to create really nice UI's, but I'd also like to find some tools that are network oriented, if anyone knows of anything.
Thanks!
Jim
|
|
|
|
|
Hello,
VS 2005
I have the following code below and I would like to remove an object from the list.
For Each timerToStop As Windows.Forms.Timer In emailTimerArray<br />
If (timerToStop.Tag = callID) Then 'Stop this timer<br />
timerToStop.Stop()<br />
timerToStop.Enabled = False<br />
emailTimerArray.Remove(timerToStop) 'Error<br />
End If<br />
Next
The error message i am getting is: "Collection was modified; enumeration operation may not execute"
<br />
Dim emailTimerArray As New List(Of Windows.Forms.Timer)
The way I am filling
emailTimer = New System.Windows.Forms.Timer<br />
emailTimer.Interval = 25000<br />
emailTimer.Enabled = True<br />
emailTimer.Tag = e.CallID<br />
emailTimerArray.Add(emailTimer)
Many thanks for any help,
Steve
|
|
|
|
|
If you're using For/Each to enumerate a collection, you can NOT modify the collection by adding/removing items.
Creating an array of Timers is not a good idea. I already told you to create a schedule and have one timer where its event checks the current time against the items in the schedule. There IS a limit to the number of timers that can be running system-wide, AND a limit to the number of timers a single process can have created, running or not.
|
|
|
|
|
I'm calling an unmanaged native WLAN API method, WlanEnumInterfaces, that returns a pointer to a structure (WLAN_INTERFACE_INFO_LIST). There are three components to the structure. The third component is an array (WLAN_INTERFACE_INFO) of variable size. The first component in the structure is the number of items in the array.
I'm having trouble marshalling the data. I am using Marshal.PtrToStructure. I get the following exception:
"Cannot marshal field 'InterfaceList' of type "WLAN_INTERFACE_INFO_LIST": Invalid managed/unmanaged type combination (Arrays fields must be paired with ByValArray or SafeArray)."
Since the array size is variable, I marshal using UnmanagedType.LPArray and SizeParamIndex.
Below is my code. The call to WlanEnumInterfaces() is successful and I can view the contents of the structure in memory. The exception occurs at Marshal.PtrToStructure.
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)> _
Public Structure WLAN_INTERFACE_INFO
<MarshalAs(UnmanagedType.Struct)> Public InterfaceGuid As GUID
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=256)> Public strInterfaceDescription() As String
<MarshalAs(UnmanagedType.I4)> Public isState As WLAN_INTERFACE_STATE
End Structure
<StructLayout(LayoutKind.Sequential)> _
Public Structure WLAN_INTERFACE_INFO_LIST
<MarshalAs(UnmanagedType.U4)> Public NumberOfItems As UInteger
<MarshalAs(UnmanagedType.U4)> Public Index As UInteger
<MarshalAs(UnmanagedType.LPArray, SizeParamIndex:=0)> Public InterfaceList() As WLAN_INTERFACE_INFO
End Structure
Dim pTemp As IntPtr
Dim WlanInterfaceList As WLAN_INTERFACE_INFO_LIST
ui32Status = WlanEnumInterfaces(WlanHandle,IntPtr.Zero, pTemp)
WlanInterfaceList = Marshal.PtrToStructure(pTemp, GetType(WLAN_INTERFACE_INFO_LIST))
Any help is appreciated.
VF
|
|
|
|
|
VFaul wrote: <marshalas(unmanagedtype.lparray, sizeparamindex:="0)"> Public InterfaceList() As WLAN_INTERFACE_INFO
Loose the SizeParamIndex field, it's only used in COM. Replace it with SizeCont:=10 . Before you call the function that is returning data in this structure, create 10 entries in your InterfaceList array so the memory is reserved for the funtion to pass data back in. You cannot pass variable length arrays because the Marshaler has no way of determining how many elements are comming back to managed code or how to read the format of the memory block. The Marshaler can copy back a single structure with PtrToStructure. It cannot handle variable length structures!
You can find some more tidbits from this[^].
It IS possible to do though! You have to supply the code to walk the memory block and pick out the values yourself. I do NOT recommend doing this because you'll be lucky to get any help making it work. It's a technique that is very very rarely ever used. There's just about no support base for it. But, for the curious -> Here it is[^].
|
|
|
|
|
I added a NotifyIcon to my project and a ContextMenuStrip so that when
the taskbar icon is clicked a menu shows up. I added the
ContextMenuStrip to the properties menu for the notifyicon. now when
i run the program when i right-click the notifyicon the first time
nothing happens, but the menu shows up the second time i click it. it
only seems to display the menu every-other click. makes no sense to
me.
I have no idea why, any help would be greatly appreciated.
|
|
|
|
|
I'm wondering what you did to get it to do this. I can't duplicate the problem, nor can I break it, to make it do what you're explaining. Did you put anny code in to enable/disable certain items in the menu at any time?
|
|
|
|
|
After posting i created a blank project with just a contextmenu and a notifyicon and it worked perfectly. Comparing the two projects i found a piece of code that i had added and forgotten to remove which was causing this problem. so if your looking for this "feature" then simply add the following
Private Sub notifyicon1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseClick
Me.Activate()
End Sub
the right click wouldn't register until it was clicked twice.
Thanks for the reply.
|
|
|
|
|
No wonder I couldn't break it!
|
|
|
|
|
Hi,
i want to determine path of system Windows folder.There r option for determine the path of Program files,my document,etc folder but no option for windows folder.
require some clue or hint. any help will be appreciated.
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
|
|
|
|