|
can i give a standed size to all my new appiering MSN boxes???
A S E L A
|
|
|
|
|
No, you have to create your own to specify size.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
how can i maximize my form when i click on maximize button on top right sid conner??? when i click it just maximize my form bu it didn't work for items in the Form i mean like ListView Boxes, text Boxes, etc....how can i do that?
|
|
|
|
|
Anchor or dock them as appropriate.
|
|
|
|
|
ya i got it...thanks a lot....
A S E L A
|
|
|
|
|
|
ya managed to do that....thanks a lot for ur advice....
A S E L A
|
|
|
|
|
i using this codes.....some times i get this error message...any one know why????
"the process cannot access the file because it is being used by another proces"
this is the message but its not using any other process...
here is my code
foreach (ListViewItem item in listView2.SelectedItems)
{
listView2.FocusedItem = istView2.Itemitem.Index]; DSOFile.OleDocumentPropertiesClass file = new DSOFile.OleDocumentPropertiesClass();
file.Open(listView2.FocusedItem.Text, false, DSOFile.dsoFileOpenOptions.dsoOptionOpenReadOnlyIfNoWriteAccess);
file.SummaryProperties.Title = tbxTitle.Text; file.SummaryProperties.Subject = tbxSubject.Text; file.SummaryProperties.Keywords = tbxKeywords.Text;
file.SummaryProperties.Author = tbxAuthor.Text; file.SummaryProperties.Comments = tbxComments.Text; file.Close(true);
MessageBox.Show("Changes Added into Selected File"); }
A S E L A
|
|
|
|
|
The file's already open, or in use somewhere. Either by another application, or by yours in unshown code.
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)
|
|
|
|
|
you know it not come out allthe time...its come out only for first picture.
in my applicartion i got two listview boxes. i load images in to one and drag drop few in to other listview box.if i drag only one picture and when i attempt to change & save summary prop i got this msg...if i drag 1 < pictures its not come out......
A S E L A
|
|
|
|
|
... then somwhere in that logic you've still got the file open.
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)
|
|
|
|
|
There are bugs in .NET wrt opening images, your best bet is to open your image, copy it to a new image, and then dispose of the old image, to make sure the file is not locked.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
copy mean temparery copy in to another folder or copy in to application.....if it is to application i don't know how to do that....but if it is to temp folder i can manage to do that....can u please just explane that bit...
thanks a lot....Christian
A S E L A
|
|
|
|
|
Hello,
Can someone suggest how I can improve the code below to use just one kind of SQL connection to read both the Database table column names and the records in the table? I am using OleDb to read the column names from the table, then SqlCommand to read the records, but I would like to use only the one or the other. How can I read the DB records using OleDb please?
Can I use SqlCommand to read the column names from the table schema?
I am using Visual C# 2005 Express.
Thank you for taking the time to read this!
using System;
using System.IO;
using System.Text;
using System.Data;
using System.Collections;
using System.Data.OleDb;
using System.Threading;
using System.Data.SqlClient;
using System.Configuration;
namespace exportToCSVfile
{
public class Program
{
static int Main( string[] args )
{
OleDbConnection connOleDB = new OleDbConnection();
connOleDB.ConnectionString = ( the connection string );
SqlConnection conn = new SqlConnection( another connection string );
DataTable schemaTable;
string strRow;
string fileOut = ConfigurationManager.AppSettings["directoryPathKey"] + ConfigurationManager.AppSettings["fileCSVNameKey"];
string fileLogFullPath = ConfigurationManager.AppSettings["directoryPathKey"] + ConfigurationManager.AppSettings["fileLogNameKey"];
if ( !Directory.Exists( ConfigurationManager.AppSettings["directoryPathKey"] ) )
{
Console.WriteLine (
"Directory \"{0}\" does not exist", ConfigurationManager.AppSettings["directoryPathKey"]);
Console.ReadLine();
return 0;
}
try
{
connOleDB.Open();
schemaTable = connOleDB.GetOleDbSchemaTable( OleDbSchemaGuid.Columns,
new Object[] { null, null, "SomeDatabaseTable", null } );
int theArrayBounds = schemaTable.Rows.Count;
string[] columnNames = new string[theArrayBounds];
for ( int i = 0; i < schemaTable.Rows.Count; i++ )
{
object objColumnNames = ( schemaTable.Rows[i].ItemArray[3].ToString() );
columnNames[i] = objColumnNames.ToString();
}
connOleDB.Close();
string sqlQuery = "SELECT * FROM SomeDatabaseTable";
SqlCommand command = new SqlCommand( sqlQuery, conn );
conn.Open();
SqlDataReader dr = command.ExecuteReader();
DataTable dtSchema = dr.GetSchemaTable();
StreamWriter sw = new StreamWriter( fileOut, false, Encoding.Default );
string columnHeaderString = String.Join( ",", columnNames );
sw.WriteLine( columnHeaderString );
while ( dr.Read() )
{
strRow = "";
for ( int i = 0; i < dr.FieldCount; i++ )
{
strRow += Convert.ToString( dr.GetValue( i ) );
if ( i < dr.FieldCount - 1 )
{
strRow += ",";
}
}
sw.WriteLine( strRow );
}
sw.Close();
conn.Close();
}
catch ( Exception exception )
{
Console.WriteLine( exception );
Thread.Sleep( 3000 );
using ( TextWriter tw = new StreamWriter( fileLogFullPath ) )
{
tw.WriteLine( DateTime.Now + "Error: " + exception.ToString() );
}
connOleDB.Close();
conn.Close();
return 0;
}
finally
{
connOleDB.Close();
conn.Close();
}
return 1;
}
}
}
I have taken help from various sources for the code and I extend my most grateful thanks;
http://www.codeproject.com/KB/database/Cs_CSV_import_export.aspx[^]
I would include other references but I've lost those links during my extensive searching.
modified on Thursday, March 12, 2009 3:49 PM
|
|
|
|
|
I have a little problem I need some help with. IM a novice C# programmer.
Im working on a piece of software that scans a directory for mp3 files loading the filepaths into an array. It then reads some info from the ID3 tags and attempts to write this info to an Access database. All seems to work fine except after about 25 files I get a System.OutOfMemory Exception. Im thinking either the ID3Info objects or the OleDbCommand objects arent disposing correctly so I threw in the System.GC.Collect and it did succeed in getting me farther but Im still getting the error. Anyone see anything Im missing?
int i = 0,duration, year;
string artist, title, album, bandname, genre, path;
string delSql = "DELETE * FROM Library";
musLibConn.ConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\GeneSys\Library.mdb";
OleDbCommand deleteLib = new OleDbCommand(delSql, musLibConn);
musLibConn.Open();
if (tbMusPath.Text != "")
{
utility util = new utility();
filepaths = Directory.GetFiles(util.getLibPath(), "*.mp3", SearchOption.AllDirectories);
deleteLib.ExecuteNonQuery();
ID3Info CurrSong;
OleDbCommand insertLib;
pBar.Visible = true;
foreach(string str in filepaths)
{
CurrSong = new ID3Info(filepaths[i], true);
path = filepaths[i].ToString();
artist = CurrSong.ID3v2Info.GetTextFrame("TPE1").ToString();
title = CurrSong.ID3v2Info.GetTextFrame("TIT2").ToString();
album = CurrSong.ID3v2Info.GetTextFrame("TALB").ToString();
lblPath.Text = path;
string insSql = "INSERT INTO Library(Artist,Title,Album,Path)"+
"VALUES('"+artist.Replace("'","''")+"','" + title.Replace("'","''") + "','"+
album.Replace("'","''")+ "','" +path.Replace("'","''") + "')";
insertLib = new OleDbCommand(insSql, musLibConn);
insertLib.ExecuteNonQuery();
i++;
System.GC.Collect();
}
pBar.Visible = false;
lblNum.Text = Convert.ToString(filepaths.Length);
util.setNoFiles(filepaths.Length);
Thanks for the help
Jon
|
|
|
|
|
Hi Jon,
adding some GC.Collect() calls is not the way to fix programming mistakes. What you need to do is call Dispose() on those objects you don't need any longer, provided their class has such a method.
In your case, insertLib = new OleDbCommand(insSql, musLibConn); is the most likely culprit: inside the loop you create OleDbCommand instances, use them, then let them fade into oblivia (by assigning a new OleDbCommand to insertLib, the old one is gone, but still occupies memory.
I suggest you do not declare OleDbCommand insertLib; outside the foreach loop, instead do
foreach (...) {
OleDbCommand insertLib=new OleDbCommand(...);
...
insertLib.Dispose();
}
that makes it perfectly clear the OleDbCommand is always created, used, disposed.
I am not familiar with some of the classes you are using (e.g. ID3Info), chances are they also have a Dispose() and need the same treatment.
ADDED
There is a useful construct that automates the above, like so:
foreach (...) {
using (OleDbCommand insertLib=new OleDbCommand(...)) {
...
}
}
The advantages are it takes less code, and the Dispose is guaranteed to occur, even when an exception gets thrown inside the using block.
/ADDED
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
modified on Wednesday, March 11, 2009 8:43 PM
|
|
|
|
|
I assume that the ID3info class (not shown) opens the file from the supplied parameters.
CurrSong = new ID3Info(filepaths[i], true);
If you have access to this classes code, make sure that the stream is disposed, if not, check to see if it has a Close or Dispose method. That might mean moving the
ID3Info CurrSong; inside the foreach loop.
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)
|
|
|
|
|
On a minor note... you have
foreach(string str in filepaths) then
path = filepaths[i].ToString(); The path field is unecessary, you can just use str in it's place.
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)
|
|
|
|
|
I have brought the declarations inside the loop, removed the System.GC.Collect and put in the insertLib.dispose(). The ID3Info class has no dispose or close method. Running the code now doesnt get me as far as with System.GC.Collect.
|
|
|
|
|
Check out Luc's added note to his previous post about wraping in a using block.
That might be the answer to the ID3Info as well (if that's the culprit). You can have nested using blocks
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)
|
|
|
|
|
Works for the OleDbCommand but not the ID3Info
It give s me this
'ID3.ID3Info': type used in a using statement must be implicitly convertible to 'System.IDisposable'
|
|
|
|
|
I've had a quick look at that code, each time you call ID3Info(string FilePath, bool LoadData) , it calls ID3v1(string FilePath, bool LoadData) which calls Load() in the same class (if LoadData is true ) which has FS.Close(); as the penultimate line, so that shouldn't be the source of your problem.
You could try changing the ID3v1 Load method to:
using (FileStreamEx FS = new FileStreamEx(_FilePath, FileMode.Open))
{
_HaveTag = false;
if (FS.HaveID3v1())
{
_Title = FS.ReadText(30, TextEncodings.Ascii);
FS.Seek(-95, SeekOrigin.End);
_Artist = FS.ReadText(30, TextEncodings.Ascii);
FS.Seek(-65, SeekOrigin.End);
_Album = FS.ReadText(30, TextEncodings.Ascii);
FS.Seek(-35, SeekOrigin.End);
_Year = FS.ReadText(4, TextEncodings.Ascii);
FS.Seek(-31, SeekOrigin.End);
_Comment = FS.ReadText(28, TextEncodings.Ascii);
FS.Seek(-2, SeekOrigin.End);
_TrackNumber = FS.ReadByte();
_Genre = FS.ReadByte();
_HaveTag = true;
}
}
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)
|
|
|
|
|
DaveyM69 wrote: so that shouldn't be the source of your problem.
unless an exception gets thrown, and got swallowed and/or not reported in the post.
Anyway your using construct fixes that.
The file data itself is the only large thing I could spot, nothing else could exhaust memory with less than 25 files, except just maybe the very first Directory.GetAllFiles().
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
|
|
|
|
|
Luc Pattyn wrote: except just maybe the very first Directory.GetAllFiles().
There would have to be a LOT of files for that to happen, but it may be possible.
Luc Pattyn wrote: unless an exception gets thrown
I didn't look at the FilStreamEx class, but I didn't see any try/catch or usings in the ID3Info or ID3v1 classes I looked at, so it's a possibility if they're not caught elsewhere.
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)
|
|
|
|
|
as far as that article goes there isn't a single "try" keyword in the entire solution.
there are several static lists/collections but I doubt they could really grow large with only 25 files.
I think I got it: there is a MemoryStream "MStream" inside FileStreamEx, it never gets Disposed().
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
|
|
|
|
|