|
Why don't you try a xml file?
|
|
|
|
|
He specifically said he's getting a line from a text file in notepad and gave an example line. XML works nicely, yes, but unfortunately not everyone uses XML to store application information
------------
Cheers,
Patrick
|
|
|
|
|
Patrick Sears wrote: If you can rely on a standard line format, it's pretty easy:
string line = "Name: Joseph Smith";
string[] parts = string.split(line, ":");
Then the parts[] array will contain the following strings:
parts[0] = "Name"
parts[1] = " Joseph Smith"
Note the space before Joseph. You could use string.Trim() to get rid of that, or you can modify the split to use StringSplitOptions.RemoveEmptyEntries.
I'm assuming you're using C#, here.
------------
Cheers,
Patrick
Hi Patrick! thanks for the help. Yes, im using C#, but i received this error
"Error 1 'string' does not contain a definition for 'split'" for string[] parts = string.split(line, ":");
do i need to import something?
thanks again
|
|
|
|
|
Split isn't a static method.Use in in a object instance and take care of the case.
|
|
|
|
|
Sorry, xibeifeijian has it right - it's an instance method, I was just indicating what class it belongs to. Sorry about that
Sometimes I'm not sure if people will understand I'm speaking in pseudocode; sort of depends on experience level which I don't know up front.
Let me know if you need anymore help figuring out how to do the parsing!
------------
Cheers,
Patrick
|
|
|
|
|
I am using Document Library in MOSS to store MS Office files to make use of IRM in MOSS. (Web application)
I want to impose expire date at document level before uploading to
document library such that even if the document is downloaded on client machine, after expiry date, the document should not open.
Thus, is there any way to impose expire date on MS office files (excel/word/power point/ infopath) using C#?
Please guide.
-- modified at 22:21 Wednesday 13th June, 2007
Regards
Sachin
|
|
|
|
|
i don't know about using c# but i guess you could add a macro to the documents concerned to either delete their own contents or inform the user that the document has expired. I know MS were talking about creating expiring e-mail etc some while ago but i never heard if they implemented it.
Russell
|
|
|
|
|
Maco can be disabled while opening the document, thus will not be useful.
We were trying to add permissions to the file ojbetcs directoy using following code but that is giving very generalized exception
"Value does not fall within the expected range"
Please have a look at the code below
------------------------------------------
<br />
using System; <br />
using System.Collections.Generic; <br />
using System.Text; <br />
using Microsoft.Office.Core; <br />
using ExcelInterop = Microsoft.Office.Interop.Excel; <br />
using Microsoft.Office.Interop.Word; <br />
<br />
<br />
class Program <br />
{<br />
private void ImposeExpiryDate() <br />
{<br />
<br />
ExcelInterop.ApplicationClass excel = new Microsoft.Office.Interop.Excel.ApplicationClass (); <br />
<br />
ExcelInterop.WorkbookClass workBook = (ExcelInterop.WorkbookClass)excel.Workbooks.Open( "c:\\test.xls", 0, true, 5, "" , "", true, ExcelInterop. XlPlatform .xlWindows, "\t", false, false , 0, true, 1, 0); <br />
ExcelInterop.Sheets sheets = workBook.Worksheets; <br />
<br />
DateTime dtExpirationDate = DateTime.Today.AddDays(2); <br />
try <br />
{<br />
workBook.Permission.Add(@"sachin@abc.com" ,Microsoft.Office.Core.MsoPermission.msoPermissionFullControl, dtExpirationDate); <br />
}<br />
<br />
catch (Exception EX) <br />
{<br />
}<br />
<br />
<br />
<br />
}<br />
<br />
}<br />
Regards
Sachin
|
|
|
|
|
Please help me as I am getting 8-12 compiler errors & suck at C++. I just want to pass this class & teacher is a jerk with no help available. What's wrong with this? I will be eternally grateful.
//******************************************************
// Filename: D4_Lab_02.cpp
// Purpose: Fix the Errors
// Author: Melissa
// Revised: April 22, 2007
//******************************************************
#include<iostream>
#include<string>
using namespace std;
void pause(void);
#define PI=3.1415
int twiceage
string last_name;
string lastname_length;
string age;
//******************************************************
// main
//******************************************************
int main(void)
{
cout << "INPUT ITEMS\n";
cout << "\nEnter your last name ----->: ";
cin >> last_name;
cout << "\nEnter how many letters are in your last name --->: ";
cin >> lastname_length;
cout << "\nEnter your age ----------->: ";
cin << age;
cout << "\nOUTPUT ITEMS\n";
cout << "\nYou said your last name was: " << last_name;
cout << "\n\nYour last name has ";
cout << lastname_length<< " letters in it.";
cout << "\n\nYour age is: " << age;
twiceage = age*2
cout << "\n\nTwice your age is: " << age*2;
cout << "\n";
for (count=0; count <5; count++)
{
cout << "\nHi Mom!";
}
cout << "\n\nThe area of a circle with a 6 inch diameter is: ";
cout << 3 * 3 * PI;
pause(void);
return 0;
}
//******************************************************
// pause
//******************************************************
void pause(void)
{
char pause;
cout << "\n\n\nHit Enter Key to Continue: ";
cin.get(pause);
cin.get(pause);
return;
}
//******************************************************
// End of Program
//******************************************************
Melissa
|
|
|
|
|
1. What are the errors you're getting? It's hard to tell you the source if we don't know what they are
2. You have several syntactical errors:
a. int twiceage needs a semicolon after it.
b. cin << age; should have the pipe pointing the other direction
c. twiceage = age*2 needs a semicolon at the end
d. technically, you don't need arguments to the pause() function, and using pause(void) in the function definition is an error - if you're going to provide a type specifier you need to provide a variable name too (the declaration at the top is fine, though). So for pause, it'd be better just to declare the function as "void pause()"
Try fixing those and let us know what further errors you get.
------------
Cheers,
Patrick
|
|
|
|
|
Thank you, Patrick.
Now it's down to 8 errors, so that is a step in the right direction- yeah!
What it's saying is...
in function 'int main()'
43 no match for 'operator*' in 'age*2'
45 no match for 'operator*' in 'age*2'
48 overloaded function with no contextual type information
48 missing'>' to terminate the template argument list
48 could not convert 'count<5>' to 'bool'
48 no post-increment operator for type
55 expected primary-expression before '=' token
57 expected primary-expression before "void"
Also, could you explain how to arrive at the answer of 9 from this expression?
29 >= 25 ? 7 + 2 : 14 - 9
Wicked thanks a lot for any & all help!
Melissa
|
|
|
|
|
wertyou wrote: 43 no match for 'operator*' in 'age*2'
Whoops. Missed this. age needs to be declared as an int; you're declaring it as a string. cin will do the work for you of converting the input to the correct type. If it happens that the input can't be converted to an integer, the value will be undefined and you'll likely get garbage when you do the multiplication (this depends on the compiler - some compilers will default the int to 0 for you, but don't depend on that behavior).
What that error is telling you is that there is no 'multiply' operator defined between a string and an integer, which is true.
wertyou wrote: 48 overloaded function with no contextual type information
48 missing'>' to terminate the template argument list
48 could not convert 'count<5>' to 'bool'
48 no post-increment operator for type
Simple - the 'count' variable isn't defined anywhere. Simply define an 'int count;' somewhere.
See if that takes care of lines 55 and 57 also.
wertyou wrote: Also, could you explain how to arrive at the answer of 9 from this expression?
29 >= 25 ? 7 + 2 : 14 - 9
That's called 'ternary' notation - the stuff before the ? is evaluated to true or false, and if it is true, the stuff between the ? and : is returned; if it evaluates to false, the stuff after the : is returned.
In this case, 29 is indeed greater than or equal to 25, so the operation returns "7 + 2" which equals 9.
------------
Cheers,
Patrick
|
|
|
|
|
Thank you for the reply. I did what you said and also added two lines about asking the persont to input a count number. So far, there are only 2 errors left! It's in line 58 and 60, saying
expected primary-expression before '=' token
and
expected primary-expression before '=' void
It's regarding the last part about the 3*3*PI -- am I defining PI wrong?
I kind of understand what you're saying about the math expression - I thought it was the one that was 1 for true and 0 for false- how can I tell them apart?
Thanks again.
Melissa
|
|
|
|
|
wertyou wrote: It's in line 58 and 60, saying
expected primary-expression before '=' token
and
expected primary-expression before '=' void
Whoops, missed that one too.
You're using this to define PI:
#define PI=3.14159
#define's don't use the equals sign - just a space, like this:
#define PI 3.14159
What you need to know here is that the compiler has a step called "Preprocessing" in which it does literal string replacement of all #define's with their values - it actually replaces those physical characters before compiling. So what the compiler is actually seeing at 3*3*PI looks like this:
cout << 3 * 3 * =3.14159;
which obviously is nonsense. That's the cause of the other error about void, too, because the compiler is getting totally confused by that equals sign.
wertyou wrote: I kind of understand what you're saying about the math expression - I thought it was the one that was 1 for true and 0 for false- how can I tell them apart?
No, the ternary operator operates on straight booleans. It will, however, interpret 1 as true and 0 as false, but those really have little to do with how the operator works.
It's pretty simple:
return CONDITION ? TRUE_EXPRESSION : FALSE_EXPRESSION;
The operator evaluates CONDITION to be true or false and returns the corresponding expression. Then, that expression is evaluated, no matter what it is. I could be a function call; it could be an integer; it can be any valid expression, really.
So, the following are all valid uses of the ternary operator:
int result = (true) ? 1 : 0; // returns 1
string result = (1) ? "yes" : "no"; // returns "yes"
string result = (0) ? "no" : "yes"; // returns "no"
int result = (29 >= 25) ? 7 + 2 : 0; // returns 7 + 2, which evaluates to 9.
And so forth.
------------
Cheers,
Patrick
|
|
|
|
|
Thanks a lot, Patrick. It seems a lot easier to understand about the ternary stuff. Also, thanks for the code help, too.
Melissa
|
|
|
|
|
Glad I could help!
------------
Cheers,
Patrick
|
|
|
|
|
I still have one error in this code and it's the following:
57 no match for 'operatr >>' in 'std::cin>> 2.8273...
and then 22 errors that are exactly the same
std:basic_istream<_CharT, _Traits>& std::basic_istream<chart, _traits="">::operator>>
Do you know what this means?
Sorry for asking again. I asked this last question to the instructor and he hasn't replied. The lab is already late.
#include<iostream>
#include<string>
using namespace std;
void pause(void);
#define PI 3.1415
int main(void)
{
cout << "\n\nThe area of a circle with a 6 inch diameter is: ";
cin >> 3 * 3 * PI;
pause(void);
return 0;
}
Melissa
|
|
|
|
|
Hi Melissa,
cin has to pipe into a declared variable; in the example you've posted, it's piping into an actual number. In that example though, it looks like you're just trying to write out what the diameter of a circle is though - so you'd change the cin to a cout.
cin is used like this:
int main(void)
{
int someValue;
cout << "Enter a number: ";
cin >> someValue;
pause(void);
return 0;
}
------------
Cheers,
Patrick
|
|
|
|
|
Thank you very much, Patrick. Now it's compiling without any problems. Oh, and I'm just now realizing that I posted my question in the wrong place- I thought the # meant any and all C question- whoops!
Thanks again.
Melis
|
|
|
|
|
No problem
wertyou wrote: Oh, and I'm just now realizing that I posted my question in the wrong place- I thought the # meant any and all C question- whoops!
Good thing you did! I don't usually go over to the C++ forum so I'd never have seen your question!
Come back soon!
------------
Cheers,
Patrick
|
|
|
|
|
Hi
1. How to enable internet explorer's "Disable script debugging option" thru code?
Is there any API which will do this operation, if so, Please give me some example code
2. Also I am doing design document update for my code, I am in need of putting class diagram and class description. I could able to create class diagram from VS studio, but i am not able generate class descriptions (like variable_name type modifier description) for all the variables,properties and functions. I can able to see those details by right click on the class diagram and class view details, but it is not allowing me to copy all the details at a time. But i am able to copy one at a time. Is there any simple way to get all class description as like as shown in class details window. (I am working in C#). so that i can copy and paste it in the document. ( i very much required this, because i have 100s of classes and its variables )
sry 2nd is repeated qn., where nobody replied for that
Thanks
srini
|
|
|
|
|
1 - Do you mean C# code, in a client side app, or javascript through a web app ? The former may be possible.
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 )
|
|
|
|
|
yes. thru C# code, it is windows application not web..
Thanks
Srini
|
|
|
|
|
hi,
My problem is that my boss told me he didn't want to everytime add a new row to datagridview he must provide new values for new row's cell. Actually. in an added row, only one or two cell need changing values, others are unchangeable. He did want to copy an existing row and paste as new row as well as change the needed values without appearing errors
I tried to use getClipboardContent() method to manually add values of an existing row to a new row but its not working. I think everybody here could help me solve this by showing me how to copy a gridview row and paste as a new row without errors or suggest me a new way to solve this. Thanks in advance
[my code]
string[] str;<br />
private void copyToolStripMenuItem_Click(object sender, EventArgs e)<br />
{<br />
DataObject obj = dataGridView1.GetClipboardContent();<br />
str = obj.GetText(TextDataFormat.CommaSeparatedValue).Substring(1).Split(',');<br />
}<br />
<br />
private void pasteToolStripMenuItem_Click(object sender, EventArgs e)<br />
{<br />
try<br />
{<br />
DataGridViewRow dgvRow = dataGridView1.Rows[0];<br />
for (int i = 1; i < str.GetLength(0); i++)<br />
dgvRow.Cells[i].Value = str[i];<br />
dataGridView1.Rows.Add(dgvRow);<br />
}<br />
catch (Exception ex)<br />
{<br />
MessageBox.Show(ex.Message);<br />
}<br />
}
It seem to be a solution or an answer.
|
|
|
|
|
Plz help me....
I want to append two or more WMV Files in C#... How can i do that????
aLi
|
|
|
|
|