472,958 Members | 1,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Setting Filename to a text field

Below code extracts the attachment and store it a share with actual
attachment name. How can I set filename to a text field's value in my
infopath form? So if attached file name is FileA.txt but the value in a text
field (FinalName) in form is FileXYZ.txt, file should be save to share as
FileXYZ.txt
-----------------------------------------------------------------------------------------------------
public void Submit_Clicked(object sender, ClickedEventArgs e)
{

// Write your code here.

XPathNavigator docXN = this.CreateNavigator();

XPathNavigator opnXN = docXN.SelectSingleNode("/my:myFields/my:Attachment",
this.NamespaceManager);

byte[] attachmentNodeBytes = Convert.FromBase64String(opnXN.ToString());

int fnLength = attachmentNodeBytes[20] * 2;

byte[] fnBytes = new byte[fnLength];

for (int i = 0; i < fnBytes.Length; i++)

{

fnBytes[i] = attachmentNodeBytes[24 + i];

}

char[] charFileName = System.Text.UnicodeEncoding.Unicode.GetChars(fnByt es);

string fileName = new string(charFileName);

fileName = fileName.Substring(0, fileName.Length - 1);

byte[] fileContents = new byte[attachmentNodeBytes.Length - (24 +
fnLength)];

for (int i = 0; i < fileContents.Length; ++i)

{

fileContents[i] = attachmentNodeBytes[24 + fnLength + i];

}

// Below is for storing to a Share

FileStream fs = new FileStream(@\\Server\EmpFiles\ + fileName,
FileMode.Create);

fs.Write(fileContents, 0, fileContents.Length); fs.Close();

----------------------------------------------------------------------------------------------------
Jun 27 '08 #1
4 2104
On Thu, 26 Jun 2008 11:15:57 -0700, andyoye <an*****@nospam.comwrote:
Below code extracts the attachment and store it a share with actual
attachment name. How can I set filename to a text field's value in my
infopath form? So if attached file name is FileA.txt but the value in a
text
field (FinalName) in form is FileXYZ.txt, file should be save to share as
FileXYZ.txt
Just use the value from your text field rather than from the file
attachment when you initialize the "fileName" variable.

Pete
Jun 27 '08 #2
How can I initialize "fileName" to get the value of form text field
"FinalName"

Thanks
"Peter Duniho" <Np*********@nnowslpianmk.comwrote in message
news:op***************@petes-computer.local...
On Thu, 26 Jun 2008 11:15:57 -0700, andyoye <an*****@nospam.comwrote:
>Below code extracts the attachment and store it a share with actual
attachment name. How can I set filename to a text field's value in my
infopath form? So if attached file name is FileA.txt but the value in a
text
field (FinalName) in form is FileXYZ.txt, file should be save to share as
FileXYZ.txt

Just use the value from your text field rather than from the file
attachment when you initialize the "fileName" variable.

Pete

Jun 27 '08 #3
On Jun 27, 12:42*pm, "andyoye" <andy...@nospam.comwrote:
How can I initialize "fileName" to get the value of *form text field
"FinalName"
fileName = FinalName.Text;

?

Jon
Jun 27 '08 #4
On Fri, 27 Jun 2008 10:33:49 -0700, andyoye <an*****@nospam.comwrote:
"FinalName" is the ID of infopath "text box" control node/field.
For what it's worth, it appears that your REAL question was "how do I get
the string value from an InfoPath 'text box' control?"

All that other stuff is just irrelevant.

You will find that you get your answers much more quickly, and much more
accurately, if you ask the questions correctly. :)

Pete
Jun 27 '08 #5

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

Similar topics

3
by: John Flynn | last post by:
hi, having problems reading from and writing back to the same file. basically, i want to read lines of text from a file and reverse them and write them back to the same file.. it has to...
18
by: Dixie | last post by:
Can I set the Format property in a date/time field in code? Can I set the Input Mask in a date/time field in code? Can I set the Format of a Yes/No field to Checkbox in code? I am working on...
3
by: Steve Yerkes | last post by:
There seems to be way too much confusion over how to set focus on the a field using a field validator. I looked all over the web and found people trying to do this, but not getting anywhere. There...
5
by: Ariel Dolan | last post by:
Can I use HtmlInputFile to only get the selected file name but not actually upload the file? Clicking the control's Browse button let's the user select a file. All I need is the HtmlInputFile...
15
by: tshad | last post by:
I am trying to put an persons email address in a response I am sending another person. I can get it to work by doing the following: message.Body = resumeTop & vbCrLf & vbCrLf & "For Applicant:...
3
by: UJ | last post by:
How can I add a browse button to my asp.net page? What I need is a button they can press that will then let them select the file to upload to the server. And if anybody has any good code on how...
1
by: simon | last post by:
I have an unbound RTF2 control in an Access 2003 form which I set to show either unformatted text or else text with words and sentences highlighted. I do this by setting the PlainText property,...
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
0
VietPP
by: VietPP | last post by:
Hi all, I've asked too much question in this day, hehe. I'm trying to export my table data in OracleDB to excel. The problem is my charset in database is US7ACSII (using Vietnamese font), when...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.