|
I want to store a Word file into a database (into a field has Image type), and get the Word file from the database to show in RichTextbox. But, when i get a byte array (named content) from database and use :
MemoryStream ms = new MemoryStream(content);<br />
<br />
<br />
richTextBox1.LoadFile(ms, RichTextBoxStreamType.RichText);<br />
to show it in RichTextbox, it throws an exception :
"Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection."<br />
Can you help me ?
|
|
|
|
|
Hi,
AFAIK an RTB is capable of showing an RTF file, which you can generate with either an RTB or
with Wordpad. An MS Word document (.doc) can not be loaded into an RTB.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Luc Pattyn wrote: Hi,
AFAIK an RTB is capable of showing an RTF file, which you can generate with either an RTB or
with Wordpad. An MS Word document (.doc) can not be loaded into an RTB.
Uhm, what i can use to show MS Word document in my application ?
|
|
|
|
|
Hi,
if MS Word is present and .doc extension is associated with it, then a WebBrowser control
should be able to show it.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
ms.Position = 0;
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hello...
I have a problem in treeview. If the treeview is focused, then I can see that the selection has a backcolor blue. But if focus changed to other control, I cannot see the selection anymore, backcolor is now white, just like another nodes.
How to keep this color blue if treeview is not focused ?
Thanks...
|
|
|
|
|
Set the treeview's HideSelection property to false. This will give it a grey background when not focused.
|
|
|
|
|
Hi,
I'm trying to add all JPG-Files from a directory to a list box with the help of following code:
const String pathFileSystem = @"\\server\c$\directory\JPG-TEST";
public void loadImagesFromFs()
{
try
{
DirectoryInfo di = new DirectoryInfo(pathFileSystem);
FileInfo[] rgFiles = di.GetFiles("*.jpg");
foreach (FileInfo fi in rgFiles)
{
this.fileList.Items.Add(fi.Name);
}
}
catch (Exception)
{
MessageBox.Show("Couldn't find directory.", "Error");
}
}
The " DirectoryInfo di = new DirectoryInfo(pathFileSystem);" allways throws me an SecurityException. It has something to do with the path. When I use System.IO.Directory.GetCurrentDirectory(); instead of the "pathFileSystem it works. But the path in the const is correct, it works on windows. And with "@" it should be correclty escaped, or not?
When I debug with "GetCurrentDirectory" the path is always with out "\\" (no escaping) but when I use the "correct version, it always has a string like "\\\\server\\directory...", which could be correct, because it escapes the "\" but I'm not sure if it isn't the problem, as it is the difference I notice in this two versions.
Any ideas?
Thx, Shi
|
|
|
|
|
I'm sure this is a permission issue. If it "works on windows", then you may have already authenticated and Windows explorer cached the credentials.
Does the user you are running your application have read rights to the path you provided? Keep in mind that the "c$" share is generally used only for admins.
If you reboot, then that should clear any cached credentials (unless you close to save them when prompted).
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
sorry, I'm normally a Java guy ( oh my gosh )
Well I tried the access to that share with my account, and on the same machine I'm developing and debugging so I'm guessing it should use the same user to access the share again, or am I wrong?
Is there a way to tell the compiler which use to use for this purpose?
Shi
|
|
|
|
|
Yes, the application should be run as the user you are logged in as and are running Visual Studio as. Does the exeception provide any specific information (maybe an InnerException?)
It's not something you "tell the complier". The compiler generates an executable and that executable is run under the context of a user. So when your executable tries to list the directory, it's using that user's credentials.
You can run the executable as a different user (than the currently logged in user), using the runas.exe command line tool or right click the EXE in Windows explorer and choose run-as. You can also have your code "impersonate[^]" another user.
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
 that's the detailed information:
System.Security.SecurityException wurde nicht behandelt.<br />
Message="Fehler bei der Anforderung des Berechtigungstyps System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089."<br />
Source="System"<br />
StackTrace:<br />
bei System.ComponentModel.ReflectPropertyDescriptor.SetValue(Object component, Object value)<br />
bei System.Windows.Forms.RadioButton.PerformAutoUpdates(Boolean tabbedInto)<br />
bei System.Windows.Forms.RadioButton.set_Checked(Boolean value)<br />
bei System.Windows.Forms.RadioButton.OnClick(EventArgs e)<br />
bei System.Windows.Forms.RadioButton.OnMouseUp(MouseEventArgs mevent)<br />
bei System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)<br />
bei System.Windows.Forms.Control.WndProc(Message& m)<br />
bei System.Windows.Forms.ButtonBase.WndProc(Message& m)<br />
bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)<br />
bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)<br />
bei System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)<br />
bei System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)<br />
bei System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)<br />
bei System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)<br />
bei System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)<br />
bei System.Windows.Forms.Application.Run(Form mainForm)<br />
bei CSharpImgPT.Program.Main()<br />
bei System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)<br />
bei System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)<br />
bei Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()<br />
bei System.Threading.ThreadHelper.ThreadStart_Context(Object state)<br />
bei System.Threading.ExecutionContext.runTryCode(Object userData)<br />
bei System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)<br />
bei System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)<br />
bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)<br />
bei System.Threading.ThreadHelper.ThreadStart()
Fehler bei der Anforderung des Berechtigungstyps ~> Error while requesting permission type
|
|
|
|
|
I found the solution for the problem...
I also played arround with some database access and it gave me also a security exception. While googling with database+exception-stuff I found following useful site which was the solution for my problem:
http://abibaby.blogspot.com/2006/02/systemdatasqlclientsqlclientpermission.html
|
|
|
|
|
Hi to all,
i have developed one application. But at the run time when i click refresh button on standard toolbar it gives the error
"The page cannot be refreshed without resending the information. Click retry to send the information again."
How can i refresh page at run time?
Pravin
|
|
|
|
|
Whenever you do a postback, you need to write your page so that you redirect to the same page, with the pertinent data on the URL. OTherwise, you're just seeing standard browser behaviour.
This was an ASP.NET question.
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|
|
Hi everyone,
I am developing a n application with asp.net 2.0 for provide our companys' customer. in home page there is one link like click here to live chat with admin. when user click on that link at that time it open new window and start the server and then client made a connection with the server with .connect method of tcpclient class.
Its good and working file now i want to notify the server when client connect with the server, So server can accept the listner from client so, how can i come to know that some body has made a connection or connected with the server.
I want to pass message from client to server and server to client.
|
|
|
|
|
Hi all,
I have a case where i need to fill in specific fields from a form and save them in specific areas in a word file.
thanks
|
|
|
|
|
Depending on which version of Word you are using, you could either open up Word via COM Interop and fill in the fields this way, or generate the file using Xml (Word uses Xml as the basis of the Docx format). Alternatively, you could take a look at VSTO (Visual Studio Tools for Office) and think about hosting the form inside Word itself.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Any links that i can start with especially that i need to save into several files once i fill the main form. Another question is that when i fill all fields with data how can i export/save them to several files without entering to each file alone
thanks
|
|
|
|
|
In windows application, i want ot access one method which on the from.cs, then how i can access that method in class without creating new intance of form in c#.
Yogesh Pekhale
pekhaleyogesh@gmail.com
|
|
|
|
|
If you want to access a method without instantiating something beforehand, you need to make that method static:
public class FunkyForm : Form
{
public static void DoSomething()
{
}
} This is called using FunkyForm.DoSomething();
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
in this static function i want to fill one list control. how i can access list control in static method.
Yogesh Pekhale
pekhaleyogesh@gmail.com
|
|
|
|
|
If it's a member of the class, you can't. That's how static methods work. If it's not a member, pass it in.
Christian Graus - Microsoft MVP - C++
"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 )
|
|
|
|
|
If you want to fill the listbox, then you need an instantiated version of the form. You could (and I stress could because it's not really the best way) expose the listbox in the form. A better approach would be to have the static handler interact with the form via events so that the form is responsible for updating the listbox by responding to events.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
I am developing windows application, in that on from i have listbox, and one statice method. i want to acess that listbox in static method then how i can?
Yogesh Pekhale
pekhaleyogesh@gmail.com
|
|
|
|