|
That was really helpful. Many thanks.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
You're welcome, off course
I are troll
|
|
|
|
|
Hi,
I am working with IMAPI2 and IMAPI2FS to burn a cd or a dvd. The sample code is shown below. I want to show a progress bar to user during cd burning. However datawriter is writing the whole image file at once. How could I generate a progress bar to show to user while it is burning?
<br />
<br />
Public Sub HellBurnIt()<br />
<br />
Dim Index As Int32 = Nothing '**<br />
Dim Recorder As New IMAPI2.MsftDiscRecorder2<br />
Dim Stream As Stream = Nothing<br />
<br />
ProgressBar3.Value = DriverSize<br />
ProgressBar1.Value = DriverFreeSpace<br />
<br />
<br />
'Here we dump all selected files under a temporary directory<br />
'<br />
Dim GetFolderPath As String = TransferFilesToTemp()<br />
<br />
Index = DriverNo ' x numbered drive on the system<br />
<br />
'Create a DiscMaster2 object to connect to optical drives.<br />
<br />
Dim G_DiscMaster As New IMAPI2.MsftDiscMaster2<br />
<br />
'Create a DiscRecorder object for the specified burning device.<br />
<br />
Dim UniqueID As Int32 = Nothing<br />
<br />
UniqueID = g_DiscMaster.Item(Index)<br />
Recorder.InitializeDiscRecorder(UniqueID)<br />
<br />
'Create an image stream for a specified directory.<br />
<br />
Dim FSI As New IMAPI2FS.MsftFileSystemImage<br />
Dim Dir As IMAPI2FS.FsiDirectoryItem = FSI.Root<br />
<br />
'Create the new disc format and set the recorder<br />
<br />
Dim DataWriter As New IMAPI2.MsftDiscFormat2Data<br />
DataWriter.Recorder = Recorder<br />
DataWriter.ClientName = TextBox1.Text<br />
<br />
FSI.FreeMediaBlocks = DataWriter.FreeSectorsOnMedia<br />
FSI.FileSystemsToCreate = FsiFileSystemISO9660<br />
FSI.VolumeName = TextBox1.Text<br />
<br />
' Add the directory and its contents to the file system <br />
Dir.AddTree(GetFolderPath, False)<br />
<br />
'Create an image from the file system<br />
'<br />
Dim Result As IMAPI2FS.FileSystemImageResult = FSI.CreateResultImage()<br />
<br />
Stream = Result.ImageStream<br />
<br />
DataWriter.Write(Stream) ' Here data writer writes the whole image <br />
<br />
End Sub<br />
<br />
<br />
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
I've never used the IMAPI2 classes, but from a quick scan of the documentation, you'd have to create an event handler for the IMAPI2.MsftDiscFormat2Data.Update event and wire it up with AddHandler.
|
|
|
|
|
i downloaded a thermometer panel but i cant figure out how to get it into visual basic. there are some files from the download but vb wont open some, what do i do
|
|
|
|
|
Send a message to the developer of the thermometer panel?
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
need some guidance, I have a collection of properties 166 to be spacific, each object in the collection will spawn a thread to perform a long running task, I also want to pump meessages back to the calling thread. threadpool will provide me the solution unfortunatly MS has limited the number of threads to 25 per processor, simple math will tell me that I need a huge box.
so that another approach would be to loop from 0 to max threadpool and spawn an instance of a thread pulling the objectid from the collection based on the threadid. that's fine or the first 50 objects. how would I now pull the remaing objects from the collection.
example
for i as 0 to threadpool.maxthreads -1
dim node as basenode = basecollection(i)
dim rem as new workernode(node)
addhandler rem.messageback new messagehandler(addressof OnMessagesReceived)
rem.dowork
next
assuming dual CPU will make the maxthread value be 50 and my basecollection will hold 166 objects
I am stuck spawning objects 51-165
|
|
|
|
|
With .NET 2.0 SP1, the default was changed from 25 threads per core to 250. This is not to say that using 250 is a good design. Seriously, if you think you need more than 25 threads per core running, you really need to reconsider your design. You'll be wasting so much time in context switching, it's silly.
Also, the ThreadPool throttles it's new thread creation to 2 per second once the thread count exceeds the number of cores running the threads. So, on a single core machine, it'll still take well over a minute to create all of your threads.
Now, having said all that, you can't change the MaxThreadPoolThreads limit in managed code.
|
|
|
|
|
this is good to hear, even though the collection will hold 165 objects, it's unlikly I will actualy spawn all 165 threads at once, each object will represent a pop3 client, that will pop a mailbox return all it's mail perform some formating, auto alerting and store the results in a DB then die. the reason for spawing as many as possible at once is reduce the time between poping, also the reason for passing messages back is for the management interface to watch activity through ipclient....
|
|
|
|
|
Hi All,
After A long time.. Hope u all are good..
I am having btnUpload and btnTransfer. On btnUpload I open a openFileDialogue select any type of file and at transfer i want to transfer it to another location suppose D:\TransferTest\.
But its giving this error Could not find a part of the path 'D:\TransferTest\'.
The code is as below :
Dim filename As String
Dim ofd As OpenFileDialog
Private Sub btnUpload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpload.Click
ofd = New OpenFileDialog()
ofd.Filter = "All Files|*.*"
ofd.ShowDialog()
If ofd.ShowDialog() = Windows.Forms.DialogResult.OK Then
filename = ofd.FileName()
txtFile.Text = filename
End If
End Sub
Private Sub btnTransfer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTransfer.Click
File.Copy(filename, "D:\TransferTest\")
End Sub
Help with a code tip... its a urgent..
Regards,
Sourabh
Thanks and Regards,
|
|
|
|
|
Try using the new filesystem namespace:
FileSystem.FileCopy(filename, "D:\TransferTest\")
|
|
|
|
|
Hi,
in Windows you can only create/move/copy files to existing folders, so if either D:\ or D:\TransferTest\ does not exist, you would get such error.
You should use Directory.CreateDirectory() to create a folder (no need to test for existence first!).
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Private Sub btnTransfer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnTransfer.Click
if not io.directory.exists("D:\TransferTest\") then
io.directory.createdirectory("D:\Tran.....")
enf if
File.Copy(filename, "D:\TransferTest\")
End Sub
|
|
|
|
|
so far for "no need to test for existence"...
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
|
|
|
|
|
First post here so please be patient, I wrote some software for the company that I work for in VB6 for Scheduling and quoting construction based projects and am upgrading to VB 2008, not a problem except for the printing, The user had several check boxes and option groups which related to which pages were printed, each unrelated, the first was a cover page, second page a preamble, third page list of doors etc all taken from different sources, in VB6 it was pretty simple to create a printer object (called myPrint) call the various page sub routines and to put it together example as below:
Select Case True
Case frmPrint.optAll(0).Value = True 'materials listing
MyPrint.NewPage
PProductListingA
Case frmPrint.optAll(1).Value = True 'bill of quantities
MyPrint.NewPage
PBOQsA
Obviously we've lost the NewPage which has been replaced with HasMorePages from with the PrintPage method, I've spent about a week now trying to call the various sub routines from within this and quite simply have hit a brick wall. Lots of examples on the web to point me in the right direction but they all seem to be based around a single block of text printed over various pages, help.
|
|
|
|
|
I cannot help you exactly on your problem, but Microsoft has an excellent article on printing in .NET:
http://msdn.microsoft.com/en-us/magazine/cc188767.aspx[^]
It helped me a lot to learn about printing in VB.NET. Note that there's some source-code relating to the article which also deals with multi-page texts. Maybe it's worth to have look. There is also a lot neat stuff in it, like status texts in status bars, print preview and so on.
|
|
|
|
|
Thanks for the suggestion, unfotunately it still only deals with a multi page single source document as opposed to a different document on mulitple pages.
|
|
|
|
|
I am using a windows forms app vb.net 3.5 SP1 w/VS 2008. I have a DS set up. I have about 4 DateTime Columns in the DS in a particular table that are defined in the SQL2005 server as DateTime NULLable. I've extended the DateTimePicker class to be able to accept a Date? value. The problem is that the DS does not believe that the date columns that are nullable, really are. It always wants to throw an exception. Per someone elses suggestion i set the date fields in the DS designer to DataType "System.Data.SqlTypes.SqlDateTime" with DefaultValue "Null", and AllowDBNull "True", yet the NullValue Property *only* allows "(Throw Exception)" and I think to fix my issue I need it to be "Null" however if I do that, the compiler says "Null is not a valid AllXsd value", which is where I'm stuck and I'm afraid is a little beyond my understanding... are there any suggestions you could make to me? I'd really appreciate it!! Thanks in advance.
|
|
|
|
|
try setting it to DBNull.Value That is the equiv. of a null in the db, "Null" is not.
|
|
|
|
|
Thanks for the reply Troy...Just tried your suggestion and the same thing happens. The actal error it gives is:
Error 44 Custom tool error: Failed to generate code. Failed to generate code. Exception has been thrown by the target of an invocation. The string 'DBNull.Value' is not a valid AllXsd value. Exception has been thrown by the target of an invocation. The string 'DBNull.Value' is not a valid AllXsd value. C:\Users\kkomar\Documents\Visual Studio 2008\Projects\Idaho AGC DataCenter\Idaho AGC DataCenter\Forms\OrganizationsFrmDataSet.xsd 1 1 Idaho AGC DataCenter
...As soon as i plug that value in.
|
|
|
|
|
personaly me I am not a fan or leaving vales null, most controls like the dataset will through a null exception, that said what I prefer to do is when filling the dataset with defaults on null
<br />
din ds as datarow = mydataset.mydatatable.newrow<br />
ds("MyDateColumn") = IIf(IsDbNull(MyDbColumn),"01/01/1900",MyDbColumn)<br />
mydataset.mydatatable.rows.add(ds)<br />
|
|
|
|
|
I appreciate the suggestion, however, I don't bind each column individually like that.
I just fill the DS and I use the designer to bind all the controls to the binding source columns.
Does this mean I'll have to manually code all the 80 column bindings on my form?
|
|
|
|
|
you can still use the designer to bind your controls to the dataset, but I personaly would use an nTier approach and create a class to fill the dataset.
From the top of my head it will go something like this, but you may want to google sqlconnection and sqlcommand on the proper implementation
public class mydataleyer
public function FillDataset() as mydataset
dim results as new mydataset
dim con as new sqlconnection("server","database","username","password")
dim qry as new sqlcommand("select * from mytable")
con.open
dim rdr as datareader = qry.executereader(cn)
while rdr.read()
dim rw as datarow = results.tables(0).newrow
rw("datecolumn") = IIF(IsDBNull(rdr(0)),"01/01/1900",rdr(0))
results.tables(0).rows.add(rw)
end while
return results
end function
end class
from you form onload event
private sub myform_load(byval sender as object,byval e as eventargs) handles mybase.load
dim ldr as new mydatalayer
me.dataset1 = ldr.FillDataset
end sub
|
|
|
|
|
Aha, so will doing:
rw("datecolumn") = IIF(IsDBNull(rdr(0)),"01/01/1900",rdr(0))
make it so that anytime that column is accessed, it will filter out the DBNull, or just for the initial loading? The reason I ask is because the date columns i have are to be re-nullable, even if they're given a value; the value has to be able to go back to null in the actual database at some point...
|
|
|
|
|
when you write values to the database you can simply reverse the logic IIF(ds("Datacolumn") = "01/01/1900",nothing,ds("datacolumn")
|
|
|
|