473,412 Members | 2,092 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

SaveFileDialog-problems

Greetings

I'm new to both .NET and Visual Basic, but I've got experience of
developing Windows-application earlier (w/o .NET or any framework).

Consider this code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim dlg As New SaveFileDialog
Dim res As DialogResult

res = dlg.ShowDialog()
If res = Windows.Forms.DialogResult.OK Then
MsgBox(dlg.FileName)
End If
End Sub
The *only* thing I want from this function is the filename that filename
that the user picked inside the dialog.

However, I get an exception in mscorlib.dll of type
"System.Security.SecurityException":

================================================== ======================
Request for the permission of type
'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
================================================== ======================

As a tip for troubleshooting, Visual Studio tells me to use the OpenFile
method to open or save a file. But this is not what I want, I want the
filename only.

Also, issuing something like dlg.InitialDirectory = "T:\" throws the same
exception.

So, I'm running into these tedious problems that I'm unaware of why it's
happening. Visual Studio tells me some file is not trusted or whatever. I
certainly don't give a ditch, but I guess there's some for me unknown
reason for this.

I would be grateful if any could straighten it out and explain why it's
happening as it does.

Thanks.
--
Rikard.
Nov 24 '06 #1
1 1103
Rikard,

I am too always in trouble with that dialog those boxes return, can you try
it this way.

Dim dlg As New SaveFileDialog
if dlg.ShowDialog <DialogResult.Cancel then
MessageBox.Show(dlg.FileName)
end if

I hope this helps,

Cor
Nov 24 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Michael A. Covington | last post by:
I've just determined, by experimenting, that regardless of its Filter and DefaultExt properties, a SaveFileDialog will let you save the file with *any* registered extension. For instance, if you...
6
by: Ken Allen | last post by:
I have enocuntered something wierd. If I invoke an instance of the above dialog and elect to save the file in a directory where a file of that name does not exist, then the return is...
2
by: Yoshi | last post by:
Hi Everyone! I am using the SaveFileDialog class. I want the user to specify the "SaveAs" filename so I can use that name when creating a text document. Here is my question below. When the...
2
by: Dennis C. Drumm | last post by:
Is there a way for the parent that calls the SaveFileDialog.ShowDialog to consume events associated with this dialog such as LocationChanged, Moved and Closed events? I had been working on a way...
5
by: juli | last post by:
Hello dear fellows! Is there any chance that you know how can I upload a file with the saveFileDialog control to a specific folder-> I want any file uploaded to be save on specific folder with...
3
by: josh | last post by:
How do I make it actually save or open a file? It only opens the dialogs. What do I type to get it to save? Here's what I have so far: Public Class frmMainApp Inherits...
2
by: ad | last post by:
Hi, I want to use saveFileDialog to save a file (like c:\aa.zip) to another place. How can I assgin c:\aa.zip to saveFileDialog
17
by: Peter Duniho | last post by:
I searched using Google, on the web and in the newsgroups, and found nothing on this topic. Hopefully that means I just don't understand what I'm supposed to be doing here. :) The problem: ...
3
by: =?Utf-8?B?UmljaA==?= | last post by:
I want to create a class library project (dll) for use with a com app. The idea is to use .Net objects in com. I also want to include a SaveFileDialog in the class library. Is it possible to...
8
by: Joe Duchtel | last post by:
Hello - I have the following code to detemine a file name when my application is saving a file. The problem is that if the file already exists and I select the Yes button in the "Do you want to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.