|
Hi all,
I have an application that was written in C# (VS 2005). The applications reads properties of ms office documents and for that purpose it uses the dsofile.dll (version 2.1) library from Microsoft. Now I'm trying to port my app. to VS 2008. But the problem is that when I try to add a reference to dsofile I get an error stating that 'Can't add a reference to the file. Please verify that the file is a valid assembly or a COM component.' Can someone please help me with it..?
Regards
Ankit.
===========================
It's done people. The problem was due to file permissions. I downloaded another copy from Microsoft and replaced the original file, and it's working fine now.
-- Modified Monday, June 14, 2010 5:49 AM
modified on Monday, June 14, 2010 5:54 AM
|
|
|
|
|
Hi all,
I need to know how to either prevent anyone from open an excel file when it's open by my application and written to or only let the file being opened write-protected during the write session.
Gurpreet
|
|
|
|
|
You might want to look at sharing and the MultiUserEditing[^] flag.
Maybe this[^] can also help.
My signature "sucks" today
|
|
|
|
|
I need to support Office 2005 as well so MultiUserEditing flag will not help. also MultiUserEditing is readonly property so I cannot set it
Also, protection property will not help in this case
Gurpreet
|
|
|
|
|
If you are opening the excel file using a filestream you could use the fileshare parameter to prevent any other users from reading the file.
|
|
|
|
|
No I am not using file stream. This is how I open and use
_objAppln = new Excel.Application(); // To initialize excel file
//_objAppln.Visible = true;
if (_objAppln != null)
{
_objWorkBooks = _objAppln.Workbooks;
_objWorkBook = _objWorkBooks.Add(Type.Missing); // To add workbook with sheets in excel file
_objWorkSheet = (Excel.Worksheet)_objAppln.ActiveSheet; // To get the current active sheet in excel file
....
Excel.Range objRange = _objWorkSheet.get_Range(columnName + _currentRowIndex, LastColumnName + _currentRowIndex);
objRange.Value2 = GroupName;
...
_objWorkBook.SaveAs(_fileName,
Excel.XlFileFormat.xlWorkbookNormal, Type.Missing, Type.Missing, false, Type.Missing, Excel.XlSaveAsAccessMode.xlNoChange,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
Gurpreet
|
|
|
|
|
Potentially you could change the read only attribute on the file as soon as you open it, and manage it that way (i.e. convert it back to read/write for the file save). This isn't perfect, though, because it would be in line for a race condition occurring.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
I need to add rows to that sheet. How can I change it to readonly?
Gurpreet
|
|
|
|
|
As soon as you open the file, change the readonly file attribute to true. Add your rows, and change the attribute to false - save - then reset to true.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Hi,
I'm using the AODL tooolkit to create spreadsheets.
The problem is, since AODL is part of open office, all the file come out as .ods files.
I'm looking for one of the following solutions:
1. A way to export files to .xls using AODL (i've searched for way of doing this, and found nothing)
2. Another toolkit, that doesn't require the installation of MS-office, and can build spreadsheets using C#.
3. Whatever other solution you think might help me...
Thank,
SummerBulb
|
|
|
|
|
private void dgvFactorSell_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
{
if (dgvFactorSell.Rows[e.RowIndex].Cells["CStoreCode"].EditedFormattedValue != null && dgvFactorSell.Rows[e.RowIndex].Cells["CStoreCode"].EditedFormattedValue.ToString() != "")
{
e.Cancel = true;
}}
now when i am in this cell and if it doesnt content any data and if i click the close button of form it doesnt do any thing (i mean it doest close the form and remain in the same cell)
ANS :http://s.codeproject.com/script/Forums/Images/smiley_smile.gif
I My Self Solved it !
bool FlagIsClose = false;
const int HTCLOSE = 0x14;
const int WM_NCLBUTTONDOWN = 0xA1;
protected override void DefWndProc(ref Message m)
{
if (m.Msg == WM_NCLBUTTONDOWN)
{
if (m.WParam.ToInt32() == HTCLOSE)
{
FlagIsClose = true;
}
}
base.DefWndProc(ref m);
}
modified on Monday, June 14, 2010 8:46 AM
|
|
|
|
|
Im Creating an RDL report Using VS 2005. It accepts a parameter which i wish to pass as an XML file.
<root>
<emp>
<emp detail ID ="1" name="ritu"/>
<emp detail ID ="2" name ="rishi"/>
</emp>
</root>
How can i filter my report data based on the ID (say 1)
|
|
|
|
|
Hi All,
I have two website 1. ABC 2. Xyz.
And i want to transfer data from one site (i.e ABC site) to another site (Xyz site).
Example:
ABC site have data (name , surname) => Pass this data to => Xyz site.
so, How can i pass this data.. Any Idea??
Thanks & Regards,
Priyanka
|
|
|
|
|
You can use HTTP post for passing the data one site to another. You just need to do is write a simple function in your app which will pass the data from your app internally. A simple code snippets is given below, I hope this might be helpful to you.
strPage = "www.codeproject.com/Get/?id=1234 ......... "
Function PostDatas(ByVal strPage As String) As String
Try
Dim oReq As System.Net.HttpWebRequest
Dim oResp As System.Net.HttpWebResponse
oReq = System.Net.HttpWebRequest.Create(strPage)
oResp = oReq.GetResponse
Dim sr As New StreamReader(oResp.GetResponseStream)
Return sr.ReadToEnd()
Catch
-- Handle exception
End Try
Thanks
Md. Marufuzzaman
I will not say I have failed 1000 times; I will say that I have discovered 1000 ways that can cause failure – Thomas Edison.
|
|
|
|
|
You might want to consider web services if you want to set up a communication channel between two web sites.
My signature "sucks" today
|
|
|
|
|
Hello CPers,
I'm trying to get a Winform to do some stuff while a button is pressed down, and stop doing it when the button's let go. I'm trying this out in a simple form with a button and a label. So as long as the button is pressed (MouseDown) the value displayed on the label should keep incrementing by 1. I've tried to used a BackgroundWorker for this and have so far failed. So, in my form class I have:
BackgroundWorker bwAsync = new BackgroundWorker();
public Form1() {
InitializeComponent();
bwAsync.WorkerReportsProgress = true;
bwAsync.WorkerSupportsCancellation = true;
bwAsync.DoWork += new DoWorkEventHandler(bwAsync_DoWork);
}
private void button1_MouseDown(object sender, MouseEventArgs e) {
bwAsync.RunWorkerAsync();
}
private void button1_MouseUp(object sender, MouseEventArgs e) {
bwAsync.CancelAsync();
}
void bwAsync_DoWork(object sender, DoWorkEventArgs e) {
BackgroundWorker bwAsync = sender as BackgroundWorker;
int i;
label1.Invoke( (MethodInvoker)delegate()
{
i = int.TryParse(label1.Text, out i) ? i : 0;
while(!bwAsync.CancellationPending){
Console.WriteLine("down");
label1.Text = i.ToString();
i++;
}
});
}
What happens here is, once it goes into DoWork() it gets stuck in the loop, and it never gets to the MouseUp handler. Anyone have any feeback on my code, or on how it's supposed to be done? Would be much appreciated.
Thank you.
modified on Sunday, June 13, 2010 11:47 PM
|
|
|
|
|
Hi,
your label1.Invoke causes the entire while loop to execute on the main thread (so it is allowed to touch the Label), however that also blocks the thread, so your button1_MouseUp handler cannot react to the button being released. (The main thread processes its event queue, popping and executing one message at a time).
Furthermore, your while loop does not contain any timing control (such as a Thread.Sleep), so it will spin as fast as it can (depending on the characteristics and the load of your system), and clogging your Console.
I would use a very different approach, without BGW:
- have a class member of type System.Windows.Forms.Timer;
- have a class member "int tickCount";
- in button1_MouseDown clear tickCount and launch that timer, with an appropriate interval (say 100 msec), and a tick handler basically containing:
Console.WriteLine("down");
tickCount++;
label1.Text=tickCount.ToString();
- in button1_MouseUp simply stop the timer.
The advantages would be: code is much simpler, everything runs on the main thread, which is idle most of the time, as all it does is run one tick handler every 100 msec.
|
|
|
|
|
THAT was ridiculously easy and clean. To think I spent the better part of the day trying to manipulate threads..
Thanks, Luc!
|
|
|
|
|
No problem.
Yes one tends to find convoluted ways first.
BTW: You may want to switch to a BGW as soon as some real work needs to be done. Then the calculations would go into the DoWork handler (without Invoke!) and hence really run on the BGW thread, however reporting progress or intermediate results to the GUI would best be handled by calling ReportProgress(), which causes the ProgressChanged handler to run on the main thread automatically.
|
|
|
|
|
Your suggestions are much appreciated. Will do
|
|
|
|
|
when u have this message Syntax error in UPDATE statement.how can slove it
|
|
|
|
|
aaga5 wrote: when u have this message Syntax error in UPDATE statement.how can slove it
by fixing the syntax of your UPDATE statement.
if you want more details, maybe you should provide more details.
|
|
|
|
|
aaga5 wrote: Syntax error in UPDATE statement.how can slove it
You can read a documentation of the UPDATE statement here[^]. Stick to the syntax described there and everything should be OK. If not, please tell us what was the query.
Greetings - Jacek
|
|
|
|
|
This is the C# forum.
My signature "sucks" today
|
|
|
|
|
Hi
I'm trying to use the name of a logical drive (c: and d . I can't use them to get access to the physical drive in order to get the type, the model, the interface, the capacity, sectors and cylinders.
My code :
private void Form1_Load(object sender, EventArgs e)
{
ManagementObjectSearcher mosDisks = new ManagementObjectSearcher("SELECT * FROM Win32_LogicalDisk");
foreach (ManagementObject moDisk in mosDisks.Get())
{
comboBox2.Items.Add(moDisk["DeviceID"].ToString());
}
}
private void button4_Click_1(object sender, EventArgs e)
{
listView2.Items.Clear()
ManagementObjectSearcher mosDisks = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive WHERE DeviceID = '" + comboBox2.SelectedItem + "'");
foreach (ManagementObject moDisk in mosDisks.Get())
{
ListViewItem item = listView2.Items.Add("Type: " + moDisk["MediaType"].ToString());
ListViewItem item2 = listView2.Items.Add("Model: " + moDisk["Model"].ToString());
ListViewItem item3 = listView2.Items.Add("Interface: " + moDisk["InterfaceType"].ToString());
ListViewItem item4 = listView2.Items.Add("Capacity: " + moDisk["Size"].ToString() + " bytes (" + Math.Round(((((double)Convert.ToDouble(moDisk["Size"]) / 1024) / 1024) / 1024), 2) + " GB)");
ListViewItem item5 = listView2.Items.Add("Partitions: " + moDisk["Partitions"].ToString());
ListViewItem item6 = listView2.Items.Add("Signature: " + moDisk["Signature"].ToString());
ListViewItem item7 = listView2.Items.Add("Cylinders: " + moDisk["TotalCylinders"].ToString());
ListViewItem item8 = listView2.Items.Add("Sectors: " + moDisk["TotalSectors"].ToString());
ListViewItem item9 = listView2.Items.Add("Heads: " + moDisk["TotalHeads"].ToString());
ListViewItem item10 = listView2.Items.Add("Tracks: " + moDisk["TotalTracks"].ToString());
ListViewItem item11 = listView2.Items.Add("Bytes per Sector: " + moDisk["BytesPerSector"].ToString());
ListViewItem item12 = listView2.Items.Add("Sectors per Track: " + moDisk["SectorsPerTrack"].ToString());
ListViewItem item13 = listView2.Items.Add("Tracks per Cylinder: " + moDisk["TracksPerCylinder"].ToString());
ListViewItem item14 = listView2.Items.Add("Description: " + moDisk["Description"].ToString());
}
}
I have used this code and it worked fine but I can't get the letters instead of the Model in the combox
private void Form1_Load(object sender, EventArgs e)
{
ManagementObjectSearcher mosDisks = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive");
foreach (ManagementObject moDisk in mosDisks.Get())
{
comboBox2.Items.Add(moDisk["Model"].ToString());
}
}
private void button4_Click_1(object sender, EventArgs e)
{
listView2.Items.Clear();
ManagementObjectSearcher mosDisks = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive WHERE Model = '" + comboBox2.SelectedItem + "'");
foreach (ManagementObject moDisk in mosDisks.Get())
{
ListViewItem item = listView2.Items.Add("Type: " + moDisk["MediaType"].ToString());
ListViewItem item2 = listView2.Items.Add("Model: " + moDisk["Model"].ToString());
ListViewItem item3 = listView2.Items.Add("Interface: " + moDisk["InterfaceType"].ToString());
ListViewItem item4 = listView2.Items.Add("Capacity: " + moDisk["Size"].ToString() + " bytes (" + Math.Round(((((double)Convert.ToDouble(moDisk["Size"]) / 1024) / 1024) / 1024), 2) + " GB)");
ListViewItem item5 = listView2.Items.Add("Partitions: " + moDisk["Partitions"].ToString());
ListViewItem item6 = listView2.Items.Add("Signature: " + moDisk["Signature"].ToString());
ListViewItem item7 = listView2.Items.Add("Cylinders: " + moDisk["TotalCylinders"].ToString());
ListViewItem item8 = listView2.Items.Add("Sectors: " + moDisk["TotalSectors"].ToString());
ListViewItem item9 = listView2.Items.Add("Heads: " + moDisk["TotalHeads"].ToString());
ListViewItem item10 = listView2.Items.Add("Tracks: " + moDisk["TotalTracks"].ToString());
ListViewItem item11 = listView2.Items.Add("Bytes per Sector: " + moDisk["BytesPerSector"].ToString());
ListViewItem item12 = listView2.Items.Add("Sectors per Track: " + moDisk["SectorsPerTrack"].ToString());
ListViewItem item13 = listView2.Items.Add("Tracks per Cylinder: " + moDisk["TracksPerCylinder"].ToString());
ListViewItem item14 = listView2.Items.Add("Description: " + moDisk["Description"].ToString());
}
}
|
|
|
|